I made a script where if you touch a part, you get 4 points. If you have 4 points, then "StarterCharacter" from ReplicatedStorage moves into StarterPlayer, and you die. When you respawn, you look like the StarterCharacter, but so does everyone else when they die.
Here is a script that checks when you join the game whether you have 4 points and creates a leaderboard:
local DSS = game:GetService("DataStoreService")
local PES = DSS:GetDataStore("PlayerExperience")
local RS = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.CharacterAdded:Connect(function(char)
local charnum = Instance.new("Model",plr)
charnum.Name = "leaderstats"
local value = Instance.new("IntValue",charnum)
value.Name = "Char"
repeat wait(.1) until char
if value.Value == 4 then
if RS:FindFirstChild("StarterCharacter") ~= nil then
char:BreakJoints()
RS:FindFirstChild("StarterCharacter").Parent = game.StarterPlayer
end
end
end)
end)
How would I make it so that only the person that touch the part gets the StarterCharacter? A bit like in Jailbreak where if you choose to be a cop, then you are a cop, it doesn't make everyone else a cop as well.
In case you need the script that's inside the part you touch, here it is:
function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = workspace[hit.Parent.Name]
local player = game.Players:GetPlayerFromCharacter(plr)
local a = true
local char = hit.Parent
if player:WaitForChild("leaderstats"):WaitForChild("Char").Value ~= 4 then
game:GetService("ReplicatedStorage").StarterCharacter.Parent = game.StarterPlayer
char.Humanoid.Health = 0
player:WaitForChild("leaderstats"):WaitForChild("Char").Value = 4
wait()
a = false
end
end
end
script.Parent.Touched:Connect(onTouch)

1 comment
How would this make a difference? It would still be added to StarterPlayer, which affects every player, right?