What do you want to achieve? When a player clicks with a tool it changes their billboard GUI text.
What is the issue? No errors and nothing happens.
What solutions have you tried so far? I have looked on the forums and tried messing around but nothing has worked.
Script inside of the tool. [LocalScript]
local tool = script.Parent
local event = game.ReplicatedStorage.KillzoneChanged
function toolused(plr)
if plr:GetRankInGroup(6170760) >= 50 then
event:FireServer(plr)
else
script.Parent:Destroy()
end
end
tool.Activated:Connect(toolused)
Script in ServerScriptService [Script]
local event = game.ReplicatedStorage.KillzoneChanged
function changetext(plr)
print("KillZone Change Recived")
local text = plr.Character.Head.PlayerTag.KillTag.Text
if text == "Killzone: Off" then
text = "Killzone: On"
elseif text == "Killzone: On" then
text = "Killzone: Off"
end
end
event.OnServerEvent:Connect(changetext)
function changetext(plr)
if plr:GetRankInGroup(6170760) >= 50 then
print("KillZone Change Recived")
local text = plr.Character.Head.PlayerTag.KillTag.Text
if text == "Killzone: Off" then
text = "Killzone: On"
elseif text == "Killzone: On" then
text = "Killzone: Off"
end
else
script.Parent:Destroy()
end
end
tool.Activated:Connect(changetext)
something like this.
Should work when you change the initial text in the textbox to âKillzone: Offâ
I havenât worked with tools in a while so I assumed you were doing it correctly yourself.
The tool can only be activated if itâs equipped do you can just get the player by doing
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
or that other solution I qouted.
If you learn to read the script you can obviously tell it wonât do anything unless the text that is already in the TextBox is either âKillzone: Offâ or âKillzone: Onâ.
if text == "Killzone: Off" then
text = "Killzone: On"
elseif text == "Killzone: On" then
text = "Killzone: Off"
end
Specify your variables correctly, please.
That is a bad practice, this is what it should look like:
task.wait()
local character = plr.Character or plr.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local Tag = head:FindFirstChild("PlayerTag")
local KillTag = tag:FindFirstChild("KillTag")
local text = tostring(KillTag.ContentText)
Also, you canât call a player using the tool.Activated event.
I suggest you do this in your LocalScript.
local tool = script.Parent
local event = game.ReplicatedStorage.KillzoneChanged
function toolused()
local plr = game.Players.LocalPlayer
if plr:GetRankInGroup(6170760) >= 50 then
event:FireServer(plr)
else
script.Parent:Destroy()
end
end
tool.Activated:Connect(toolused)