Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i change the variable from the player to a zombie?

How do I change this script from when the player dies money is added to when a zombie called "Humanoid" in workspace dies money is granted.

game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild(player).Died:Connect(function()
            player.RealMoney.Value = player.RealMoney.Value + 1000
        end)
    end)
end)

2 comments

0

How can i show you the properties

0

"Humanoid" is the name of the zombie and its parent is workspace

1 answer

✓ Accepted answer

1 game:GetService('Players').PlayerAdded:Connect(function(player)

2 player.CharacterAdded:Connect(function(character)

3 character:WaitForChild("Humanoid").died:connect(function()

4 local getLocation = character.HumanoidRootPart.Position

5 local zombie = game.ReplicatedStorage.Humanoid

6 local newZombie = zombie:clone()

7 newZombie.HumanoidRootPart.Position = getLocation

8 newZombie.Parent = game.workspace.spawnedZombies

9 end)

10 end)

11 end)

Notes Create a folder in workspace called "spawnedZombies. Move the Humanoid to replicatedStorage. when entering the script place it in server script service.

If you have any problems friend my account share the project and I can help fix the script.

This discussion is preserved as it was. New answers, comments, and votes are closed.