So i really wanted to know how to make players grab an item one at a time but i got to the point where a players get all the same item at once like the video shown below:
My script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("OverseerSword")
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Team = game:GetService("Teams"):FindFirstChild("Green")
local cloneSword = Sword:Clone()
cloneSword.Parent = player.Character
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("OverseerSword")
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Team = game:GetService("Teams"):FindFirstChild("Green")
if not (player.Character:FindFirstChild(Sword.Name) or player:FindFirstChild("Backpack"):FindFirstChild(Sword.Name)) then
--Clone sword
local cloneSword = Sword:Clone()
cloneSword.Parent = player.Character
end
end
end)
Just curious is this a proper way of using debounce if yes then why isn’t the script working?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("OverseerSword")
local debounce = false
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Team = game:GetService("Teams"):FindFirstChild("Green")
if not debounce then
debounce = true
wait(1)
local cloneSword = Sword:Clone()
cloneSword = player.Character
debounce = false
end
end
end)
Kinda wanna know when to use debounce or not
I’ve tried your code and it works but i wanna know when to use debounce