So I’m trying to have it so that when you equip a weapon, it waits until you have died to equip it. But this script doesn’t seem to be working. The print statement is not going off.
Script:
local button = script.Parent
local player = game:GetService("Players").LocalPlayer
button.Activated:Connect(function()
game.ReplicatedStorage.EquippingNextRound:Fire()
player.CharacterAdded:Wait()
print("Equipping Baseball Bat.")
end)
I can provide any other necessary scripts etc. just ask.
The code below would print the player’s name, followed by “has died!”, whenever a player dies. For example, if the player was named “Batmanissupercoolbro”, “Batmanissupercoolbro has died!” would be printed to the output when you died.
Secondly, to equip a tool to a player you should get the bat you plased in your game (like in ReplicatedStorage or ServerStorage), and parent it to the players backpack.
This is an example on what I mean:
local bat = game.ReplicatedStorage:WaitForChild("Bat")
bat:Clone().Parent = player.Backpack
This is a script inside the ‘StarterGui’ container meaning that it’s being cloned into the local player’s ‘PlayerGui’ container each time their character is added/loaded.
Move the script to the StarterPlayerScripts container and reference the gui from there.