Refresh character by touching a part

so in my game we work with character effects, material changing and particles on the character. although people have told me they are annoyed that they have to reset to remove the effect so they suggested a refresh part. i have this script which refreshes the character with a button but i want it by touching a part.

player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:Connect(function()

    if workspace:FindFirstChild(player.Name) then
        workspace[player.Name]:LoadCharacter()
    end

end)
5 Likes

You could use the .Touched event:

local Players = game:GetService("Players")
local debounce = false

Part.Touched:Connect(function(partTouched)
	if partTouched.Parent:FindFirstChild("Humanoid") then
		local Character = partTouched.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
		Player:LoadCharacter()
	end
end)

when i touch it i still have the effects.

Have you made the script that changes the appearance of the character or is that done by an admin (free model) script such as kohl’s admin?

its in a script. (30 characte)

Yes… I know that, i am asking if you’re using a free model admin script though.

nope, i made the script together with this site.

Can you send the code? The issue could be that the effects are applied even after the Character is re-loaded.

i forgot how to use script frames so ill just send it like this:
first script:
local part = workspace:WaitForChild(“MChanger2”) --Change to the actual part name inside Workspace
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent.Humanoid.Health > 0 then
for _, part in ipairs(hit.Parent:GetChildren()) do
if part:IsA(“BasePart”) and not part:FindFirstChild(“Fire”) then
local fire = Instance.new(“Fire”)
fire.Color = Color3.fromRGB(128, 187, 219)
fire.Parent = part
end
end
end
end)

second script:
workspace[“MChanger”].Touched:Connect(function(touch)
if game.Players:GetPlayerFromCharacter(touch.Parent) then – To verify if its a player
local Childrens = touch.Parent:GetDescendants()-- Get the children
for i,v in ipairs(Childrens) do – For loop through the Children
if v:IsA(“BasePart”) then – If v or value is a basepart (basepart is basically a superclass of all types of parts)
v.Material = Enum.Material[“ForceField”] – change the Material of v which is the part.
end
end
end
end)

(both in a normal script)

Weird… there’s nothing in that script that i can see that would cause that problem.

I doubt this will do anything but try destroying the character before you load it:

local Players = game:GetService("Players")
local debounce = false

Part.Touched:Connect(function(partTouched)
	if partTouched.Parent:FindFirstChild("Humanoid") then
		local Character = partTouched.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
		Character:Destroy()
        Player:LoadCharacter()
	end
end)

in script or local script (30 cha)

In a script, which is inside the part.
Change “Part” To “Script.Parent”

theres an orange line under the script in script.parent

is it script.Parent with a capital P
and
Do you have the script under the part?

yes, that works but it respawns the player. any way without respawning?

You would have to move them to the exact part position so it would not look like they respawn but since they have force fields

I think you should just stay with the respawn

To do that is more complicated, You need to store the BrickColor of the player’s character in a dictionary.
then you need to iterate through the character’s descendants and remove particle emitters etc.

It’s easier to do what @Mixu_78 and @FerbZides said.

that worked but maybe add a cooldown because i was stuck in an infinite loop of teleporting in the same place

Because, if he doesn’t want to respawn the character, and if the brickcolor of the player’s baseparts have been changed, he will need to store them to fetch them and revert them to the original.

It’s very impractical and complicated (as i’ve stated) and your methods would be better off used, again (as i’ve stated)

that didnt teleport me anymore