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
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.
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)