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

How do I make this script work in a part with a click detector?

Asked by 10 years ago

So I got this script to kill all players, but I want it to only work after the brick it is in is clicked. This is the script:

for i,v in pairs(game.Players:getPlayers()) do
v.Character:breakJoints()
end

2 answers

Log in to vote
2
Answered by
Kozero 120
10 years ago

First of all the methods you wrote are case sensitive so it won't work the way you wrote them. The proper way of writing getPlayers is GetPlayers.breakJoints is supposed to be BreakJoints. Make sure you Check the Object Browser in Roblox Studio to check all the events,methods and properties for each object. Help-->Object Browser.

If theMouseClick event is fired then it will connect the function and run it.

function ClickTime(Plyr)
for i,v in pairs(Players:GetPlayers()) do
v.Character:BreakJoints()
end
end
script.Parent.ClickDetector.MouseClick:connect(ClickTime)

Make sure the ClickDetector object and the script are inside the Part.

Ad
Log in to vote
0
Answered by
OniiCh_n 410 Moderation Voter
10 years ago
local detect = script.Parent.ClickDetector -- Assuming the script is within a part, and the part has a ClickDetector in it

function kill()
        for i, v in pairs(game.Players:getPlayers()) do
        v.Character:breakJoints()
end

detect.MouseClick:connect(kill)

Answer this question