Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This touched event will not take away time. Could someone help me?

Asked by 4 years ago

Ok, so I was making a game and this script did not work. And I was wondering if anyone could help.



local function touched() script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Beans") then script.Parent.Parent.BeanPosition.Transparency = 0 print("Player has beans!") local player = game.Players:GetPlayerFromCharacter(hit.Parent) print(player.Name.." needs their beans removed.") local light = script.Parent.Parent.Carpet.SurfaceLight light.Enabled = true script.Parent.Parent.BeanPosition.Script.Disabled = true hit.Parent.Beans:Destroy() game.ReplicatedStorage.Time.Value = game.ReplicatedStorage.Time.Value - 30 end end) end while wait(5) do spawn(touched) end
0
please expand your question with what it is you're trying to do in the description. Don't just paste the code in, otherwise it makes it harder for us to read and respond. Either way, you're making a few easily fixable mistakes I can help with if you edit the question and publish it properly Wiscript 622 — 4y
0
The while true do will not work the way you want it to since your never disconnecting the touched event(though thats not a good way to do what I think your wanting) ForeverBrown 356 — 4y

Answer this question