I am trying to make a script which enables Leaderstats once a part is touched and disabled once the touching is done, but after trying lots of different solutions I have failed.
I do not understand why this is occouring and I need help making this
ServerSided Script for .touched Event:
script.Parent.Touched:Connect(function(Part)
if Part and Part.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Part.Parent) then
print("something")
script.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(Part.Parent))
end
end)
script.Parent.TouchEnded:Connect(function(Part)
if Part and Part.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Part.Parent) then
warn("ended")
script.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(Part.Parent))
end
end)
you made a silly mistake if not passing a boolean argument for the remote event on the server side for the touched events.Its always gonna return nil for BoolVal.
script.Parent.Touched:Connect(function(Part)
if Part and Part.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Part.Parent) then
print("something")
script.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(Part.Parent),true)
end
end)
script.Parent.TouchEnded:Connect(function(Part)
if Part and Part.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Part.Parent) then
warn("ended")
script.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(Part.Parent),false)
end
end)