Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(DESPERATE) I want to destroy a script when a part is touched. Anyone know how to fix this?

I want to destroy the gravity controller script for that player only when that player touchs the floor part anyone know how I can fix this? I dont want the gravity controller deleted for everyone though, just for that player!

local part = script.Parent
part.Touched:Connect(function(hit)
    if part.Name == "Floor" then 
        script.GravityController:Destroy()
    end
end)

3 answers

Local script:

local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild( "Humanoid") then 
    if part.Name == "Floor" then 
        part.GravityController:Destroy()
    end
end)

2 comments

0

gravity controller is script..

0

the gravity controller is a script

If FilteringEnabled is enabled, just make that script a local script and put it within the local player (PlayerGui, Backpack, character, etc.). You'd obviously change line1 to be game.workspace.Part or wherever your part is located. Alternatively, you could go the RemoteEvent route, but the simpler way that I stated seems fit for you

You might not want to destroy the script you should probably disable it instead

script.Parent.GravityController.disabled = false 

This discussion is preserved as it was. New answers, comments, and votes are closed.