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

onTouched function only working in studio and not in game ?

Asked by
xdeno 187
6 years ago

-The script is inside a part in the Workspace -When it is touched the below script activates -It works perfectly in studio but not in game, any ideas ?

local debounce = false
local debounce2 = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DropBallClientEvent = Instance.new("RemoteEvent", ReplicatedStorage)
DropBallClientEvent.Name = "DropBallClientEvent"

script.Parent.Touched:connect(function(hit)
    if debounce2 == true then return end
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        debounce2 = true
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.Team == game.Teams["-Home GK"] then
            if player.Backpack.LocalVariables:WaitForChild("ObjectHeld").Value ~= nil then
        DropBallClientEvent:FireClient(player)
    end
        end
        end
wait(1)
debounce2 = false
end)
0
Line 8, change connect toConnect. User#19524 175 — 6y
0
lowercase connect still works tho, that's hardly the issue ? xdeno 187 — 6y
0
Deprecated code can cause problems. User#19524 175 — 6y
0
My entire game works on deprecated code then oh noes, but that wasn't the problem it was with player.Team in line 13, I really appreciate the response though thank you so much. xdeno 187 — 6y

Answer this question