im making a skateboard system for a game im working on and whenever a player respawns it needs to spawn them a board, my previous way of doing so was using playeradded but it didnt work on the respawn: here is what im currently trying to do but its not working,
function add(character)
local player = game:GetService("Players"):GetPlayerFromCharacter(character)
game.Workspace:WaitForChild(player.Name)
game.Workspace[player.Name]:WaitForChild("HumanoidRootPart")
Board = game.ServerScriptService.Board:Clone()
M6D = Instance.new("Motor6D", player.Character.HumanoidRootPart)
M6D.Part0 = player.Character.HumanoidRootPart
M6D.Part1 = Board.PrimaryPart
Board.Parent = player
end
function remove()
Board:Destroy()
M6D:Destroy()
end
function onplayeradd(player)
player.CharacterAdded:Connect(add)
player.CharacterRemoving:Connect(remove)
end
game:GetService('Players').PlayerAdded:Connect(onplayeradd)
here is what it was BEFORE:
game.Players.PlayerAdded:Connect(function(player)
game.Workspace:WaitForChild(player.Name)
game.Workspace[player.Name]:WaitForChild("HumanoidRootPart")
local Board = game.ServerScriptService.Board:Clone()
local M6D = Instance.new("Motor6D", player.Character.HumanoidRootPart)
M6D.Part0 = player.Character.HumanoidRootPart
M6D.Part1 = Board.PrimaryPart
Board.Parent = player.Character
end)