r/robloxgamedev • u/PURPLREGUY • May 28 '26
Help Me With Coding Help Debugging A Script
I was trying to make a script that would change the lighting of the game for one player and teleport the same player, but upon moving it to a local script it doesn't work at all.
script.Parent.Touched:Connect(function(Hit)
`if Hit and Hit.Parent:WaitForChild("Humanoid") then`
`local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)`
`Player.Character:MoveTo(Vector3.new(-588, -59, 3177))`
`local weatherScript = game.Workspace["Advanced Thunderstorm Simulator"]`
`weatherScript["Lightning/Thunder"]:Destroy()`
`weatherScript["Rayblons Rain Simulator"]:Destroy()`
`weatherScript["Rayblons Wind Simulator"]:Destroy()`
`weatherScript[":)"].Spin.Enabled = false`
`game:GetService("Lighting").EnvironmentDiffuseScale = 0.7`
`game:GetService("Lighting").EnvironmentSpecularScale = 0.7`
`game:GetService("Lighting").Ambient = Color3.fromRGB(255, 183, 0)`
`-- Lighting Edits And Thunderstorm Stopper`
`end`
end)
1
Upvotes
View all comments
Show parent comment
1
u/raell777 May 29 '26
I was referring to the Variable for the touched part, is that
If that is the part that is going to be touched write this for your Variable instead
You probably need a debounce in your touched event also. When a part is touched, code runs so fast that it will register many times really fast. To slow this down and control it you use a debounce and a task.wait(), that way the touch only occurs once within that time frame. After the task.wait(), you flip the debounce back. A debounce is just a boolean of true or false.