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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
0
gravity controller is script.. Nistrict 44 — 4y
0
the gravity controller is a script Nistrict 44 — 4y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

script.Parent.GravityController.disabled = false 

Answer this question