I am trying to make a hamster ball and i want it to stay on the player all the time however with the current script you have to walk up to it and then when u respawn it doesn’t respawn with you. How do i make it stay on the player always?
-- Script --
colors = {"Bright blue","Bright red","Bright green","Bright yellow","Bright orange"}
script.Parent.BrickColor = BrickColor.new(colors[math.random(1,#colors)])
function touch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
local stuff = hit.Parent:GetChildren()
for i = 1,#stuff do
if stuff[i].ClassName == "Hat" then
stuff[i]:Destroy()
end
end
game.Players:FindFirstChild(hit.Parent.Name).Character.Torso.CFrame = script.Parent.CFrame + Vector3.new(0,.5,0)
script.Parent.Parent = hit.Parent
local w = Instance.new("Weld")
w.Part0 = hit.Parent.Torso
w.Part1 = script.Parent
w.Parent = hit.Parent.Torso
while true do
wait()
h.Sit = true
end
end
end
script.Parent.Touched:connect(touch)
you can add a server script to connect a function to the player as soon as they enter and have it check if the player has respawned. From there you have the players directory.
So for the respawn problem you could just never have them die. So check if their humanoid health is equal to zero then change it to 100 if it is. You could just parent the ball to the player.