Hello, it’s me again ^^ i have a script for drop a specific loot for my players in a specific radius, the script works good but just one player win the loot xD we are 4 players in radius but just one win object “BraceletBois” it is possible to drop for all players in range ?
My script:
local heal = script.Parent.Ennemy
range = 80
bounce = 1
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
while wait(1) do
if heal.Health <= 1 then
if bounce == 1 then
bounce = 0
local fox = script.Parent.PrimaryPart.Position
local dist = (fox - player.Character.PrimaryPart.Position).magnitude
local xp = player.status.XP
if dist <= range then
xp.Value = xp.Value + 450
local fox = game.Workspace.Boss.Fox
fox.Parent = game.Lighting
local number = math.random(7,10)
if number == 7 then
local bracelet = game.ReplicatedStorage.Items:WaitForChild('BraceletBois')
bracelet:Clone().Parent = player.Backpack
elseif number == 8 then
local bracelet = game.ReplicatedStorage.Items:WaitForChild('BraceletBois')
bracelet:Clone().Parent = player.Backpack
elseif number == 9 then
local bracelet = game.ReplicatedStorage.Items:WaitForChild('BraceletBois')
bracelet:Clone().Parent = player.Backpack
elseif number == 10 then
local bracelet = game.ReplicatedStorage.Items:WaitForChild('BraceletBois')
bracelet:Clone().Parent = player.Backpack
wait(30)
bounce = 1
local fox = game.Lighting.Fox
fox.Parent = workspace.Boss
end
end
end
end
end
end)
end)
When you make bounce 0, it is 0_for everyone. So if someone else joins the game, bounce will be 0 from the last guy. Also, bounce is pointless in this case. You can just do while wait(30) do, and it will wait 30 seconds either way.
You mean messing with transparency? In that case you have to grab all of the models children and set their transparency mode to 1 (transparency can only be done with parts).
I have made this but it’s not working i don’t know why:
function respawn()
local model = script.Parent -- your model (script.Parent.Parent in your current case)
local descendants = model:GetChildren() -- you can use :GetChildren() if there are not BaseParts parented to another BasePart
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("BasePart") then
descendant.Transparency = 1
wait(30)
descendant.Transparency = 0
end
end
end
descendants and children are different things, I see you named your GetChildren() string that. GetDescendants() grabs children from children all the way down the ancestory. if your model has parts with children down to children then you will want to use GetDescendants(). Also just say :IsA("Part"), BasePart is not needed in there.
This will wait 30 before changing it back to 0 and doing the next loop, so it would take forever to go through every part. Try this instead:
-- This loop will make all the children of the model's transparency 1
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("BasePart") then
descendant.Transparency = 1
end
end
wait(30)
-- This loop will make all the children of the model's transparency 0
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("BasePart") then
descendant.Transparency = 0
end
end
function respawn()
local model = script.Parent -- your model (script.Parent.Parent in your current case)
local descendants = model:GetDescendants() -- you can use :GetChildren() if there are not BaseParts parented to another BasePart
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("Part") then
descendant.Transparency = 1
wait(30)
descendant.Transparency = 0
end
end
end