I'm currently using the function destroy() to reset the player, but due to the map, this will mess up the leaderboard deaths. Instead of editing the leaderboard to remove the kill made by the UI, is there any type of function which can refresh the player instead?
Thanks.
Hey Aceros,
local part = script.Parent; -- Variable for the part that is going to make the Character load. local players = game:GetService("Players"); -- Variable for the Players Service local debounce = false; -- Variable for debounce (Like a cool down) part.Touched:Connect(function(obj) -- Anonymous function connected to a .Touched event. local hum = obj.Parent:FindFirstChild("Humanoid"); -- Variable for the humanoid to check if the player even has one. if hum and debounce == false then -- Variable checking if debounce is false and if there is a humanoid. debounce = true; -- Sets debounce to true so that the function won't run again until it's false. print("Reloading Character.."); -- Prints "Reloading Character" local char = obj.Parent; -- Variable for the Character local plr = players:GetPlayerFromCharacter(char); -- Variable for the Player using :GetPlayerFromCharacter() local shirt = char:WaitForChild("Shirt"):Clone(); -- Variable for the shirt. local pants = char:WaitForChild("Pants"):Clone(); -- Variable for the pants. plr:LoadCharacter(); -- Loads the Character back to spawn point. local new_char = plr.Character; -- Variable for the new character (Necessary because you are parenting the pants and shirts to the new character, not the old one. shirt.Parent = new_char; -- Sets parent of the shirt to the new character (Necessary to set the shirt and pants because for some reason when you use the :LoadCharacter() method it doesn't load the Character's Shirt and Pants. pants.Parent = new_char; -- Sets the pants' parent to the new character. wait(0.5) -- Amount of time it will wait before it can be touched again. debounce = false; -- Sets debounce to false so that the function is allowed to be activated. end -- end for the if statement end) -- end for the anonymous function.
~~ KingLoneCat