Hello, I’m making a railgun arena in my game and currently, I have the gears in a separate team so that when touch part, it changes their team and resets them.I do however want to change this so that when a player walks on the team changing brick, it also gives them the railgun without duplicating or resetting and can be removed when it walks on another part - and be able to walk on the other part again and still give them the same gear.
There’s no script to give the player a railgun since the railgun is only given on a reset after a team change.
I would check if the railgun is in his backpack or character (equipped) already.
local part = ...
local railgun = ...
local name = railgun.Name
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") or hit.Parent.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local character = humanoid.Parent
local player = Players:GetPlayerFromCharacter(character)
local backpack = player.Backpack
if not backpack:FindFirstChild(name) and not character:FindFirstChild(name) then
railgun:Clone().Parent = backpack
end
end
end)
Add bool Value to the part set it to false and when player touches it it will change to true and when it’s true you can’t get the tool reply to me od you don’t understand cuz my English is bad
Bool value is a value that can be true or false, you can set it to true and to false in script so do something like that
-- it will work when script parent is part that gives you a tool and bool value is inside this part
local bool = script.Parent.Value
script.Parent.Touched:Connect(function()
if bool.Value == false then
bool.Value = true
-- give tool
end
end)
Yes, as a serverscript.
So don’t give him a tool, just destroy it?
Make it
local part = ...
local railgun = ...
local name = railgun.Name
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") or hit.Parent.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local character = humanoid.Parent
local player = Players:GetPlayerFromCharacter(character)
local backpack = player.Backpack
local found = backpack:FindFirstChild(name) or character:FindFirstChild(name)
if found then
found:Destroy()
end
end
end)