Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm making a bossfight, and I want it to give the player a sword?

Asked by 4 years ago

Right now, I've made it so it shows a button to get the sword. What could I do to make it GIVE them the sword instead of them clicking a button?

Here is the script:

1wait(0.5)
2game.Workspace.Cave:Stop()
3wait(1)
4for _,player in pairs(game.Players:GetPlayers()) do
5                player.PlayerGui.ScreenGui.TextButton.Visible = true
6end
7wait(2)
8    game.ServerScriptService.bossfightScript.Disabled = false

1 answer

Log in to vote
0
Answered by 4 years ago

Something you can do is get yourself a clone of the sword:

1local SwordClone = game.ReplicatedStorage.Sword:Clone()

and do something like

1local SwordClone = game.ReplicatedStorage.Sword:Clone()
2for _,player in pairs(game.Players:GetPlayers()) do
3    SwordClone.Parent = player.Backpack
4end

But somethings wrong.. it will only give it to one player, thats cause we only have one copy of the sword, an easy solution around this is:

1for _,player in pairs(game.Players:GetPlayers()) do
2    local SwordClone = game.ReplicatedStorage.Sword:Clone()
3    SwordClone.Parent = player.Backpack
4end

this way we get one copy of the sword for every player we find and put it in their backpack.

I hope this helps!

0
Thank you so much! DriBowser 55 — 4y
Ad

Answer this question