I have this tool, it's just a handle and a localscript. The problem is when I try to make a gui appear on the users screen that was touched by the tool it says their PlayerGui does not exist..
The problem is this part: P:FindFirstChild("PlayerGui").ScreenGui.BeHostile.Visible = true
How can I fix this?
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer
local tool,db = script.Parent,false
script.Parent.Activated:connect(function()
tool.Handle.Touched:connect(function(Plr)
local P = game.Players:FindFirstChild(Plr.Parent.Name)
if P and not(Plr.Parent.Name == Player.Name) then
if tool.Enabled == true then
local Info = P:FindFirstChild("StoredInfo")
local Hostile = Info:FindFirstChild("Hostile")
if Info and Hostile then
if P.TeamColor == game.Teams.Inmate.TeamColor then
if P.Character.Humanoid.Health >= 1 then
if Hostile.Value == true then
if db == false then
db = true
Hostile.Value = false
P:FindFirstChild("PlayerGui").ScreenGui.BeHostile.Visible = true --Here is the problem.
game.Workspace[Plr.Parent.Name].Torso.CFrame = CFrame.new(game.Workspace["InmateSpawns"]["Spawn"..math.random(1,4)].Position)
wait(1)
db = false
end
end
end
end
end
end
end
end)
end)
|