of     1   

Intevoid
#182997062Thursday, February 04, 2016 8:39 PM GMT

So I'm making a brick that adds a value to a value, and them deletes the brick when clicked. It's not working, and I can't find out the error, so can somebody take a look at the script? local replicatedstorage = game:GetService("ReplicatedStorage") local sticks = replicatedstorage:WaitForChild("Sticks") function onClicked(playerWhoClicked) sticks.Value = sticks.Value + 1 wait(0.25) script.Parent.Parent:Destroy() end ClickDetector.MouseClick:connect(OnClicked)
Egzekiel
#182997243Thursday, February 04, 2016 8:43 PM GMT

ClickDetector.MouseClick:connect(OnClicked) You didn't define ClickDetector. Also, it's possible the script doesn't work if you use a WaitForChild on an instance that's already present local sticks if not replicatedstorage:FindFirstChild("Sticks") then sticks = replicatedstorage:WaitForChild("Sticks") end
Intevoid
#182997543Thursday, February 04, 2016 8:49 PM GMT

I defined it, but it still says "OnClicked" is unknown.
Intevoid
#182997917Thursday, February 04, 2016 8:56 PM GMT

Bump.
BanTech
#182998658Thursday, February 04, 2016 9:11 PM GMT

onClicked not OnClicked
Intevoid
#182998858Thursday, February 04, 2016 9:15 PM GMT

Thanks, little errors like that can screw up everything, lol.
Intevoid
#182998925Thursday, February 04, 2016 9:16 PM GMT

Script still not working. Here's what I have: local replicatedstorage = game:GetService("ReplicatedStorage") local sticks = replicatedstorage:WaitForChild("Sticks") local ClickDetector = script.Parent local sticks if not replicatedstorage:FindFirstChild("Sticks") then sticks = replicatedstorage:WaitForChild("Sticks") end function onClicked(playerWhoClicked) sticks.Value = sticks.Value + 1 wait(0.25) script.Parent.Parent:Destroy() end ClickDetector.MouseClick:connect(onClicked)
BanTech
#183000251Thursday, February 04, 2016 9:38 PM GMT

Well first of all you don't need this: local sticks if not replicatedstorage:FindFirstChild("Sticks") then sticks = replicatedstorage:WaitForChild("Sticks") end Secondly, is Sticks definitely a child of replicated storage? It may be that near the top, the WaitForChild never gets fulfilled. If both of those are fine, then check the output. Are there any errors?
Intevoid
#183000635Thursday, February 04, 2016 9:45 PM GMT

I'm not getting any errors.
Intevoid
#183000719Thursday, February 04, 2016 9:47 PM GMT

Also, here's my hierarchy.
Intevoid
#183000792Thursday, February 04, 2016 9:48 PM GMT

https://gyazo.com/0af55aa1f21462e41b7dcbf816f231c9 There you go, sorry.
TimeTicks
#183001079Thursday, February 04, 2016 9:53 PM GMT

script.Parent.ClickDetector.MouseClick:connect(function(player) local stats = player:WaitForChild("leaderstats") local sticks = stats:WaitForChild("Sticks") sticks.Value = sticks.Value + 1 script.Parent:Destroy() end)
Intevoid
#183001178Thursday, February 04, 2016 9:55 PM GMT

@Time So would I need this? ClickDetector.MouseClick:connect(onClicked)
TimeTicks
#183001338Thursday, February 04, 2016 9:58 PM GMT

Nope. Its already in there.
Intevoid
#183001440Thursday, February 04, 2016 9:59 PM GMT

This still isn't working. local replicatedstorage = game:GetService("ReplicatedStorage") local sticks = replicatedstorage:WaitForChild("Sticks") local ClickDetector = script.Parent script.Parent.ClickDetector.MouseClick:connect(function(player) local stats = player:WaitForChild("leaderstats") local sticks = stats:WaitForChild("Sticks") sticks.Value = sticks.Value + 1 script.Parent:Destroy() end) Should I get rid of: local sticks = replicatedstorage:WaitForChild("Sticks")
TimeTicks
#183001780Thursday, February 04, 2016 10:05 PM GMT

--Is sticks a Value inside of ReplicatedStorage? If it is then just do this. --I thought you were trying to change a players stats. local sticks = game.ReplicatedStorage:WaitForChild("Sticks") script.Parent.ClickDetector.MouseClick:connect(function(player) sticks.Value = sticks.Value + 1 script.Parent:Destroy() end)
Intevoid
#183003681Thursday, February 04, 2016 10:41 PM GMT

This still isn't working.
Intevoid
#183003711Thursday, February 04, 2016 10:41 PM GMT

Also, it is not giving me any errors.
ez_street
#183007392Thursday, February 04, 2016 11:36 PM GMT

The reason its not working is because its a localscript, it needs to be a normal script.
Intevoid
#183016685Friday, February 05, 2016 2:02 AM GMT

@iMung I changed it, but it still didn't change anything.
usermvp
#183018491Friday, February 05, 2016 2:30 AM GMT

Is there a VALUE in the item "Sticks" that's name is "Value" or is Sticks an IntValue? Insert this into a REGULAR script, then insert the script into a part that you want the Players to click for it to happen. Make sure there IS a ClickDetector in the item. local rs = game:GetService("ReplicatedStorage") local sticks = rs:FindFirstChild("Sticks") print("Variables loaded") script.Parent.ClickDetector.MouseClick:connect(function() script.Disabled = true sticks.Value = sticks.Value + 1 wait(0.25) script.Parent:remove() script.Disalbed = false end) Unless you want it to be a leaderstat value, then I can script that.

    of     1