#Objective script not working

1 messages · Page 1 of 1 (latest)

proud haven
#

So, i made a script that should change whenever the player interacts with the proximity prompt but it doesn't work. Im gonna send the sceenshot and see if someone can fix it.

proud haven
proud haven
torpid beacon
proud haven
#

alr

torpid beacon
#

you are referencing startergui, use (playerhere).PlayerGui

proud haven
#

let me try

torpid beacon
#

to get the player i recommend you using a local script, however, you can reference to the plr via the triggered func

proud haven
#

so do i type the player user in (playrhere)?

torpid beacon
#

question

#

where r you running this script

#

client or server

proud haven
#

the child is proximity promt and im on edit mode right now

#

im not a great scripter

torpid beacon
proud haven
#

you mean if its local script or not?

torpid beacon
#

yeah

proud haven
#

its not local

torpid beacon
#

oh well then

proud haven
#

but (playerhere) doesn't like get corrected

#

when i type in script

torpid beacon
#

reference the plr via the func, you should give the player an instance bool value so it doesnt trigger different because a previous player alr activated it

proud haven
#

alr lemme try

torpid beacon
#

you can give the boolvalue with a playeradded func

#

by that you can replace the wash value

proud haven
#

where do i put playgui

#

*playergui

torpid beacon
proud haven
#

k

torpid beacon
#

(plrinstance).PlayerGui

#

and it has the same stuff like startergui (unless you add specific guis to some players)

proud haven
#

can you like explain it more idiot friendly?

sharp sequoiaBOT
#

studio** You are now Level 2! **studio

proud haven
#

im a new dev

#

started scripting yesterday-

torpid beacon
# proud haven explain more idiotfriendly?

ok basically you have this bowl of fruits, which containst your guis, when a player joins, this bowl of fruits gets cloned in another location called playergui, which is what you see on your screen by client, this bowl of fruitsis cloned to every player, however this apple can be changed by some scripts if you wish to, like adding a pear (another screen gui) or etc

#

the bowl of fruits is located on the player

proud haven
#

i understand

#

but how do i fix the script now

wispy birch
torpid beacon
#

yeah

#

starter scripts

#

etc

torpid beacon
proud haven
#

this is how my script looks like now

#

local TextUI = game.StarterGui.Objective.TextUI
local Text = TextUI.Text
local wash = false
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
Text = ("Objective: Explore the House")
print("Text changed")
else
wash = false
Text = ("Objective: Wash Your Hands")
print("did wrong")
end
end)

torpid beacon
#

basically what your script is doing is changing a value, but this value can be changed by everyone anytime, however the value is always the same for everyone, causing it to show different texts on screen on activated

#

example

#

noob1 activates it and gets the normal message

#

and the proximityprompt text is changed

proud haven
#

not the proximity promt text

#

the objective text

#

in startergui

torpid beacon
#

oh yeah

#

forgot

#

however

#

noob2 activates it again

#

but he gets the other message and gets confused

#

since the old value was still there

#

i dont know if you want that to happen

proud haven
#

ohhh

torpid beacon
#

but yeah

proud haven
#

so how do i do it now that it works for both players. Like changes on both screens when one activates it

torpid beacon
#

or be for the only player who activates it

proud haven
#

yeah

#

i want it to be multiplaer

#

*player

torpid beacon
#

right

proud haven
#

yea

torpid beacon
#

okay

sharp sequoiaBOT
#

studio** You are now Level 11! **studio

torpid beacon
#

you can try gettting the children with a loop

proud haven
#

what children

#

of the proximity?

#

my brain's not braining

torpid beacon
#

this gets the players in the current server at time

#

oh wait

#

ok done

#

playergui is just like starter gui

proud haven
#

so do i put it in the script that is the child of the proximity prompt?

#

or just a new script in server script service

torpid beacon
#

red = delete
blue = replace

#

replace those lines with the loop i gave you

proud haven
#

without the end right?

torpid beacon
#

the entire loop

#

copy everything from that tiny script

proud haven
#

but then its end and the text underneath doesn't run

torpid beacon
#

ok hold on

torpid beacon
proud haven
#

sure

#

local TextUI = game.StarterGui.Objective.TextUI
local Text = TextUI.Text
local wash = false
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
Text = ("Objective: Explore the House")
print("Text changed")
else
wash = false
Text = ("Objective: Wash Your Hands")
print("did wrong")
end
end)

#

ping me when your finished

torpid beacon
#

local wash = false
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren() do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
end
end
print("Text changed")
else
wash = false
for i,plr in pairs(game.Players:GetChildren() do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
end
end
print("did wrong")
end
end)

#

this should wokr

#

@proud haven

proud haven
#

alr

#

lemme try

torpid beacon
#

however

proud haven
#

yea`?

torpid beacon
#

this is for the current players in time

#

so if a player joins

#

after the function happened

#

the message wont be shown

#

i can help with that too but

proud haven
#

so what if one player's got a potato pc and takes time to load in?

torpid beacon
#

going to sleep rn

proud haven
#

alr, when your awake again u can dm me

torpid beacon
#

its a more complex script

#

but it can work

proud haven
#

dang

#

@torpid beacon

#

still doesn't work

torpid beacon
#

also i might've made a typo since

proud haven
#

l

sharp sequoiaBOT
#

studio** You are now Level 3! **studio

proud haven
#

*k

torpid beacon
#

i made that script on note blocks

proud haven
#

or i can screenshare

torpid beacon
#

i cant rn

proud haven
#

in vc of this server

#

ok

torpid beacon
#

also gn

proud haven
#

lemme send screenshot of console

torpid beacon
#

ok thats a typo

#

ill correcct it tomorrow

proud haven
#

alr

torpid beacon
#

cya

proud haven
#

dm me when ur finished

#

cya

meager geyser
#

Close the bracket

proud haven
#

at do?

meager geyser
#

pairs

proud haven
#

this the script

#

local wash = false
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren() do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
end
end
print("Text changed")
else
wash = false
for i,plr in pairs(game.Players:GetChildren() do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
end
end
print("did wrong")
end
end)

#

im a new and not good dev 😭

meager geyser
#

Line 8, you're not closing the bracket in pairs. This means you're missing the ")" or "(".

sharp sequoiaBOT
#

studio** You are now Level 7! **studio

proud haven
#

do i do ) at the do

#

like there

meager geyser
#

infront of it

proud haven
#

on the right of the line?

#

or on the right of the pairs

meager geyser
#

Infront of do

proud haven
#

alr

meager geyser
#

) do

proud haven
#

oh

#

alr

meager geyser
#

another one of it is missing, find it

proud haven
#

the other do?

meager geyser
proud haven
#

alr

#

the error is fixed

#

now for the final moment...

#

yay

#

it works

proud haven
# meager geyser -

and how do i do it that the objective changes to "Objective: Go Outside" in 15 seconds?

meager geyser
#

just like what you wrote plrgui.Objective.TextUI.Text = "Objective: Explore the House"

proud haven
#

so i replace the textlabel with plrgui.Objective.TextUI.Text = "Objective: Explore the House"
`?

meager geyser
#

@proud haven Textlabel is the original name for the object itself, the name can be changed

proud haven
#

oh

#

then its textui

meager geyser
#

yeah

proud haven
#

i dont think it would work

#

do i replace both textuis?

meager geyser
#

whats the need for replacing

proud haven
#

you said i should replace it with plrgui.Objective.TextUI.Text = "Objective: Explore the House"

meager geyser
#

i never said replace

proud haven
#

u said change

#

oh

#

i mean like

#

in the script that it changes

#

not that i change it manually

#

because if i would change it manually it would already be at the start

#

and i want it after the "explore the house"

meager geyser
#

you're changing the text property of the textlabel

proud haven
#

yeah

meager geyser
#

find the textlabel, get text property and set it to = "Objective: whatever"

proud haven
#

in the script?

meager geyser
#

yes

proud haven
#

i mean like

#

here

#

local wash = false
local Prompt = script.Parent
print("variables done")

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
task.wait(15)

            end
        end 
        print("Text changed")
else
    wash = false
    for i,plr in pairs(game.Players:GetChildren()) do
            if plr:IsA("Player") then
                local plrgui = plr.PlayerGui
                plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
            end
        end 
        print("did wrong")
end

end)

#

where should i replace it

#

because i need the objective things for the start

#

only after the task.wait i want to change the textr

proud haven
#

yeah??

#

to check if it set the variables

slender valve
#

...

proud haven
#

for debugging

#

yeah im not a great dev

slender valve
#

so not for those i saw there

proud haven
#

alr

#

i deleted the print

slender valve
#

what is script.Parent.Triggered?

proud haven
#

when it triggered the proximity prompt which is the parent of the script

slender valve
#

okay just wanted to know that

proud haven
#

i want to like make it change the objective again after the task.wait

slender valve
#

what do you want to change?

proud haven
#

the text of the objective

#

the tex property of "TextUI" the text label

slender valve
#

yeah

proud haven
#

i want it to change after task.wait

#

and im not a good scripter

#

so idk how do to the script

slender valve
#

okay so just change the text after task.wait

proud haven
#

yeah and how do i do it

slender valve
#

after the task.wait()

#

do

TextUI.Text = "Whatever you want"

proud haven
#

let me try

#

this error pops up

slender valve
#

oh, its a Server Script?

proud haven
#

yeah

#

not local

slender valve
#

but you want to change the UI?

proud haven
#

the text

slender valve
#

so just make a RemoteEvent

proud haven
#

of the textlabel

sharp sequoiaBOT
#

studio** You are now Level 5! **studio

proud haven
#

how do i do remote events 😭

slender valve
#

ReplicatedStorage

#

click on the "+" and add RemoteEvent

proud haven
#

what should i call it

slender valve
#

change the name to something like "SinkTextModule"

proud haven
#

k

#

or i call it ExploredHouseModule

slender valve
#

in your Server Script type:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Module = ReplicatedStorage:WaitForChild("Module")

[Change Module with the correct name]

proud haven
#

on where

#

like under the task.wait?

slender valve
#

and at the end of the 15 seconds do:

Module:FireClient(player)

slender valve
#

in local Script do:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Module = ReplicatedStorage:WaitForChild("Module")

local player = game.Players.LocalPlayer

Module.OnClientEvent:Connect(function()

end)

#

and then you can write the Code inside the Module

proud haven
#

what local script-

slender valve
#

the TextLabel is inside the PlayerGui, correct?

proud haven
#

my brain isn't braining

slender valve
#

then just put the local Script inside the ScreenGui

proud haven
slender valve
#

then do that what i did, and add the Labels, etc. and Change the Text inside the Module.OnClientEvent

#

yeah

proud haven
#

what should i type on it

hardy nimbus
proud haven
slender valve
#

gtg now buy some stuff

proud haven
#

windows xp sound

proud haven
#

i think pyro fire can help me?

proud haven
#

what now

meager geyser
#

learn the basics

proud haven
#

i already did

meager geyser
#

what is object hierarchy

proud haven
#

uh

#

..

hardy nimbus
proud haven
#

...

meager geyser
#

you said you learned the basic

meager geyser
#

wat is object hierarchy

proud haven
#

i js want my game finished to play it with my friends

#

thats the entire reason i joined this server

hardy nimbus
proud haven
#

no, just to get help scripting

#

to understand scripting more clearly

hardy nimbus
#

the difference between those people and people who have games are the ones who have games put in the time, effort, and the hard work (or robux) to make it happen 👍

proud haven
#

i wanna put hard work

hardy nimbus
proud haven
#

i don't care if it takes 3 months

#

i want to be a better scripter

#

and every script i type i also wanna understand

hardy nimbus
#

and perhaps an understanding that you aren't going to get your code perfect and flawless on your first try, you're going to run into problems you don't understand, there's where google comes in fingerguns

proud haven
#

lol

hardy nimbus
#

some people do and it's not pretty for them ;o

proud haven
#

how can i become better

#

without having to watch blender gurus tutorial in roblox studio version

hardy nimbus
# proud haven how can i become better

i've been telling you how. read the docs. practice. make simple things. watch tutorials for ideas and concepts, but do not copy, reproduce it in your own way

proud haven
#

ok

#

im trying

hardy nimbus
#

believe it or not but all games are just lots of small simple things all connected to each other

proud haven
#

ik

hardy nimbus
#

and the thing about guis are, go figure, buttons don't do anything without a script connected to it.

#

healthbars dont move without a script connected to it.

#

you didn't finish the gui step.

proud haven
#

i have a text

#

i have a script

#

the player interacts with the sinks to wash is hands

#

the tex changes from wash your hands to explore the house

#

the player walks around

#

after 15 seconds

#

the objective changes to "go outside"

hardy nimbus
#

what part of this exactly are you stuck on?

proud haven
#

on the thing after 15 seconds

#

where it is suppose to change the objective

hardy nimbus
#

task.wait(15) then update the objective same way you did before.

#

task.wait does exactly what it says on the tin - it waits.

proud haven
#

im stupid

#

i could've just read the script and paste the ones that change the objective 😭

#

@hardy nimbus

#

can you explain me this error?

hardy nimbus
proud haven
#

i can't understand

#

that why i asked

hardy nimbus
#

why can't you understand it?

#

understanding errors is probably the most important part of coding

proud haven
#

i can see that it mentions the script of the proximity prompt

hardy nimbus
#

yes, what else does it mention?

proud haven
#

where do i learn to understand errors?

hardy nimbus
#

you could google the error

#

or you could read it

#

sometimes the error isn't clear, but this one is

proud haven
#

"expected 'end' ( to close 'then at line 5)

hardy nimbus
#

don't fall into the newb trap of going oh red text, panic!

proud haven
#

thats what i dont understand

#

i don't panic

hardy nimbus
proud haven
#

i just wanna figure it out

#

let me see

#

if wash == false then

hardy nimbus
proud haven
#

to close it with a (?

hardy nimbus
#

how do you normally write an if statement?

proud haven
#

if ohio == script.parent then
print("idk")

proud haven
#

at the top

local ohio = game.workspace.things.ohio

#

if "something happens" then
-- Make something else happen
end

#

i typed it right

#

OH

#

END

hardy nimbus
#

there it is fingerguns

proud haven
#

but i already put and end ther

hardy nimbus
proud haven
#

local wash = false
local Prompt = script.Parent

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
end
task.wait(15)

            for i,plr in pairs(game.Players:GetChildren()) do
                if plr:IsA("Player") then
                    local plrgui = plr.PlayerGui
                    plrgui.Objective.TextUI.Text = "Objective: Go Outside"
            end
        end 
        print("Text changed")
else
    wash = false
    for i,plr in pairs(game.Players:GetChildren()) do
            if plr:IsA("Player") then
                local plrgui = plr.PlayerGui
                plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
            end
        end 
        print("did wrong")
end

end

hardy nimbus
#

so which do you think is more likely: you did put an end, or you did not?

proud haven
#

at the if plr part

#

after the thing there is end

hardy nimbus
#

maybe that end is for something else?

#

this is why indentation helps a lot

#

correct indentation, i should say.

proud haven
#

i put end

#

under prompt:destroy()

hardy nimbus
proud haven
#

as i learned they said spaces dont matter

hardy nimbus
#

a closure is anything that needs an 'end' after it.

#

like an if statement, for statement, functions, etc.

proud haven
#

is closure ")"?

hardy nimbus
#

no a closure is the end

#

the error for missing ) is different

proud haven
#

there i added end

sharp sequoiaBOT
#

studio** You are now Level 6! **studio

hardy nimbus
proud haven
#

alr

#

7

hardy nimbus
#

;compile lua ```lua
if a then
if b then
if c then
for a in {1,2} do
-- stuff
end
end
end

inner boughBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:8: 'end' expected (to close 'if' at line 1) near <eof>

hardy nimbus
#

you can see there's 4 opening closures, and only 3 ends.

proud haven
#

;compile lua ```lua
if a then
if b then
if c then
for a in {1,2} do
-- stuff
end
end
end
end

inner boughBOT
#
hardy nimbus
#

if i mess up the indentation like you do in your code, it is far less obvious

#
if a then
    if b then
  if c then
    for a in {1,2} do

      end
  end
 end
proud haven
#

:compile lua
``alocal wash = false
local Prompt = script.Parent

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
task.wait(15)
end
end
end

    ``
hardy nimbus
#

yeah thats not going to work

proud haven
#

;compile lua
``alocal wash = false
local Prompt = script.Parent

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
task.wait(15)
end
end
end

    ``
inner boughBOT
#
Critical error:

You must attach a code-block containing code to your message or quote a message that has one.

hardy nimbus
#

anyway, you have a missing end, go look for it.

#

go through your entire code line by line if you have to.

proud haven
#

hm

hardy nimbus
#

do this this one time, and hopefully you'll learn how to deal with them easier in the future when you figure out what is stealing their end from the if statement the error mentions.

proud haven
#

4 closures

hardy nimbus
#

i've already spotted it but it's up to you to fix your own code. you know what's wrong with it now, so go fix it fingerguns

proud haven
#

so was i right with 4 closures?

hardy nimbus
#

count the closures, and the ends.

#

like this

proud haven
#

4 closures and 4 ends

hardy nimbus
#
if a then -- +1
  if b then -- +1
  end -- -1
  for x in {1,2} do -- +1
end -- -1```
#

if you have +1 or more at the end, you have a missing end. if you have -1 or less, you have too many ends.

#

pretty simple

#

anyway i gotta go do some stuff gl

proud haven
#

i added 5 closures

#

so its 0 now

#

i don't understand anything

slender valve
#

@proud haven

proud haven
#

ye?

slender valve
#

can you send me your script?

proud haven
#

k

#

local wash = false
local Prompt = script.Parent

script.Parent.Triggered:Connect(function(plr)
if wash == false then
wash = true
print("Wash variable done")
for i,plr in pairs(game.Players:GetChildren()) do
if plr:IsA("Player") then
local plrgui = plr.PlayerGui
plrgui.Objective.TextUI.Text = "Objective: Explore the House"
Prompt:Destroy()
task.wait(15)
end
end
end
end
end

            for i,plr in pairs(game.Players:GetChildren()) do
                if plr:IsA("Player") then
                    local plrgui = plr.PlayerGui
                    plrgui.Objective.TextUI.Text = "Objective: Go Outside"
            end
        end 
        print("Text changed")
else
    wash = false
    for i,plr in pairs(game.Players:GetChildren()) do
            if plr:IsA("Player") then
                local plrgui = plr.PlayerGui
                plrgui.Objective.TextUI.Text = "Objective: Wash Your Hands"
            end
        end 
        print("did wrong")
end

end

#

there was also this error

#

Workspace.Things.Sink.SinkProximityPrompt.ProximityPrompt.Script:18: Expected ')' (to close '(' at line 4), got 'end'

slender valve
#

so this isnt working?

pale cipher
proud haven
#

but the thing with the 15 secs doesn't work

slender valve
sharp sequoiaBOT
#

studio** You are now Level 18! **studio

slender valve
#

the one you send me is the one you use atm?

proud haven
#

the same one that also runs the interaction of the sink

slender valve
#

you should learn the basics...

proud haven
#

i did

slender valve
#

for loops, Proximity Prompt, playergui / Gui, Triggered Event

proud haven
#

but i still dont figure out

proud haven
#

i want a script teacher

#

bc tutorials dont help

slender valve
#

uh i dont really have time

#

I'm making my own game, sorry

proud haven
#

or when you take breaks

#

i do everything

#

and i will listen

#

pls

#

i can also test your game and tell bugs

slender valve
proud haven
#

i can join you

#

and help you find bugs

slender valve
proud haven
#

u can also add me to just playtest

#

or you can add me and give me permissions to play the gamre on roblox

slender valve
proud haven
#

i can show u

slender valve
#

alr whats ur user

proud haven
#

SilasPapadopoulos

#

ima go eat

#

after i ate i can try ur game

slender valve
#

i added you to Roblox Studio as playtester

proud haven
#

ima join when i finished eating

slender valve
proud haven
#

cya

slender valve
#

cya

proud haven
#

i js find bugs

slender valve
#

its just like UI and Script

proud haven
#

i can't find the game to join

#

u mean in roblox studio?

#

or in roblox

slender valve
#

roblox studio

proud haven
#

whatss the game called

slender valve
#

YouTube Infinity Simulator

proud haven
#

where can i find the game?

slender valve
#

i dont know

proud haven
#

yo

#

german

#

i also speak german

slender valve
#

nice

proud haven
#

seems like im not finding it

slender valve
#

hmm

proud haven
#

lemme add you to my game to see if you can join it

slender valve
#

kk

proud haven
#

i added you

#

try to join it

slender valve
#

nope

proud haven
#

uh

#

well

#

lemme add u in roblox then

slender valve
#

my user is vinni_090509

proud haven
#

i added u

#

i made that friends only can test the game

#

so maybe u can play it now

proud haven
#

nice

#

join me on rblx

slender valve
#

i still dont see it

proud haven
#

join me

#

on roblox

#

the application

#

not roblox studio

slender valve
#

kk

#

i cant type in chat

#

which objective?

proud haven
#

it only shows in roblox studio

#

and i need help on the next objective

#

why can't you chat tho

slender valve
#

im on my laptop

#

and its first person

proud haven
#

press "-"

#

or §

#
  • or §
slender valve
#

i have to script my game now xD

proud haven
#

they both activate chat

proud haven
#

wait

#

go to permissions and enable friends only

#

so i can test it out

slender valve
#

permission in Roblox Studio or on the Roblox Website?

proud haven
#

roblox sutido

#

*studio

#

then type friends only

#

so only friends can test ur game

slender valve
#

i can only choose between Public and Privat

proud haven
#

do private

#

friends only tho

#

wai

slender valve
#

i have it on private

proud haven
#

i call u on dms

#

we both mute

#

and i do screen share