I have a script that used to work. I changed some small stuff with the script and the game and now some of the script doesn't activate when the Parent is touched. The GameMusic is successfully destroyed, but the print() that is above it doesn't work.
local subject = script.Parent local debounce = true local player = game.Players.LocalPlayer script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")and debounce == true then debounce = false print("player has touched") game.SoundService.GameMusic:Destroy() player.character.Humanoid.WalkSpeed = 0 wait(12.5) script.Parent.Error.Playing = true script.Parent.BrickColor = BrickColor.new(255, 0, 0) end end)
LocalPlayer
is not defined in server scripts, you can get player by hit.Parent(which should be character)
local subject = script.Parent local debounce = true script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- try to get player from character if player and debounce == true then -- if is a valid player debounce = false print("player has touched") game.SoundService.GameMusic:Destroy() player.Character.Humanoid.WalkSpeed = 0 wait(12.5) script.Parent.Error.Playing = true script.Parent.BrickColor = BrickColor.new(255, 0, 0) debounce = true -- you forgot to reset debounce, so it can be touched again end end)