So here I have a script, if player is within the distance of 5, its makes GUI visible. This script works fine but I want to be able for this script to check if the player that is within the Distance of 5 has the tool name "Gun" currently equipped.
If the player has the gun equipped and within the distance of 5, then breakjoints? how would I go about doing this?
I have tried v.Character.Gun in replacement of v.Character.Torso.. but that somehow didn't work.
brick = script.Parent
distance = 5
local newThread = coroutine.create(function()
while wait() do
for i, v in pairs(game.Players:GetPlayers()) do
if v.Character and v.Character.Torso and (v.Character.Torso.Position - brick.Position).magnitude < distance then
v.PlayerGui.CtS.Frame.Visible = true
end
if v.Character and v.Character.Torso and (v.Character.Torso.Position - brick.Position).magnitude > distance then
v.PlayerGui.CtS.Frame.Visible = false
end
end
end
end)
coroutine.resume(newThread)
