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)
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)
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)
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)
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.
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)