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

Make this script run again on character respawn?

Asked by 5 years ago
Edited 5 years ago

Right now, this script only runs when the player enters, then never runs again. I want to make it run again when the player respawns, but I'm not sure how I would go to doing this.

local wings = game.ReplicatedStorage.Wings
local mps = game:GetService("MarketplaceService")

game:GetService("Players").PlayerAdded:Connect(function(player)
    if mps:UserOwnsGamePassAsync(player.UserId,5260848) then
        local function createMachine()
            local wingsClone = wings:Clone()
            wingsClone.PrimaryPart = wingsClone.Base
            wingsClone.Parent = player.Character
            wingsClone:moveTo(player.Character.Torso.Position)

            local weld = Instance.new("Motor6D")
            weld.Parent = wingsClone.Base
            weld.Part0 = wingsClone.Base
            weld.Part1 = player.Character.Torso
        end
        createMachine(player)
    end
end)
0
Just make it Touched function, and add it to the Spawn Point, it will do it always when he touches the spawn point. BuilderMfriend1 -5 — 5y
0
just use the CharacterAdded event of the player, which fires when the character loads or respawns User#23365 30 — 5y
0
How would I go to applying that to this script? I tried multiple ways, but it's only a event of player so it's kind of difficult to do Starflyerz 44 — 5y

1 answer

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
5 years ago
Edited 5 years ago

Use the CharacterAdded Event.


local wings = game.ReplicatedStorage.Wings local mps = game:GetService("MarketplaceService") game:GetService("Players").PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() if mps:UserOwnsGamePassAsync(player.UserId,5260848) then local function createMachine() local wingsClone = wings:Clone() wingsClone.PrimaryPart = wingsClone.Base wingsClone.Parent = player.Character wingsClone:moveTo(player.Character.Torso.Position) local weld = Instance.new("Motor6D") weld.Parent = wingsClone.Base weld.Part0 = wingsClone.Base weld.Part1 = player.Character.Torso end createMachine(player) end end) end)
Ad

Answer this question