Hello! I’m trying to make a script where when you spawn in you get your weapon. But when another player spawns in, the first player who spawns gets a second tool.
I’ve tried making an if statement preventing that from happening
Script
Also it’s a local script in startergui, so you know.
Can you copy and paste the script here.
And also use the preformatted text when showing code so its easier to fix problems, just click on it and you will be able to paste the code in it
local touched = false
function touch()
local Player = game.Players.LocalPlayer
if not Player.Character:FindFirstChildWhichIsA("Tool") then
wait(1)
print(Player)
print(Player.PlayerGui)
print(Player.PlayerGui.Weapons)
print(Player.PlayerGui.Weapons.RockEquipped)
print(Player.PlayerGui.Weapons.RockEquipped.Value)
print(Player.PlayerGui.Weapons.RockEquipped.Value == true)
if Player.PlayerGui.Weapons.RockEquipped.Value == true then
game.Workspace.Lobby.Show.Rock.Handle.Anchored = false
game.Workspace.Lobby.Show.Rock.Handle.Transparency = 0
game.Workspace.Lobby.Show.Rock.Parent = Player.Backpack
end
end
end
game.Workspace.SpawnIn.Touch.Touched:Connect(function()
if not touched then
touched = true
touch()
wait(2)
touched = false
end
end)
It does everything right, it just gives the player that spawned first, another rock (weapon) when another player spawns.
I think this line isn’t working properly:
if not Player.Character:FindFirstChildWhichIsA(“Tool”) then
You have to rewrite your whole script from what I understand or put the tool to starterpack but if you are willing to make a script you have to make a new script that is not a localscript in serverscriptservice
And put this in it:
local touched = false
function touch()
local Player = game.Players.LocalPlayer
if not Player.Character:FindFirstChildWhichIsA("Tool") then
wait(1)
print(Player)
print(Player.PlayerGui)
print(Player.PlayerGui.Weapons)
print(Player.PlayerGui.Weapons.RockEquipped)
print(Player.PlayerGui.Weapons.RockEquipped.Value)
print(Player.PlayerGui.Weapons.RockEquipped.Value == true)
if Player.PlayerGui.Weapons.RockEquipped.Value == true then
game.Workspace.Lobby.Show.Rock.Handle.Anchored = false
game.Workspace.Lobby.Show.Rock.Handle.Transparency = 0
game.Workspace.Lobby.Show.Rock.Parent = Player.Backpack
end
end
end
game.Workspace.SpawnIn.Touch.Touched:Connect(function()
if not touched then
touched = true
touch()
wait(2)
touched = false
end
end)
Line 4 is not working. I’m trying to make a system that stops you from getting multiple tools.