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

How do I make a team change UI respawn instead of kill?

Asked by
Zeluxis 100
7 years ago

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.

0
Why are you using Destroy() when you could be using BreakJoints() or maybe just setting the humanoid's health to 0? It might work, but I'm too lazy to test it lol Podnf 22 — 7y
0
That'd have the same effect; just killing the humanoid and then adding a wipeout Zeluxis 100 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Hey Aceros,

I've been working on what you've asked about for like the past 30 minutes or so and I already knew that :LoadCharacter() method would be the correct method but, because of my inexperience of it's usage, I wasn't quiet sure so, I made a game that you can take a copy of that I will mention later in the answer and I am also gonna provide you with an explanation of how :LoadCharacter() works. Below is a personal example.

Personal Example:

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.

Anyways, here is my game. In there you will be able to see a blue brick and a red brick and if you touch the blue one, it will reload you and if you touch the red one, it will kill you. The game is un-copylocked so you can take a copy and look at the code I did and use it as an example! Don't copy others people's code. I also did data storage for the game and leaderstats to record your death so you can have a more relative point for what you need help with.

Well, I hope I helped in one way or another and have a great day/night.

~~ KingLoneCat

0
Lol, most of those lines are taken up by comments. The code isn't that much. KingLoneCat 2642 — 7y
Ad

Answer this question