I have a GUI where you can turn particle effects of players off but when the player dies the particles
come back so how could I make them turn off every time the player respawns or just turn them off for good
(Im a beginner scripter so any help is appreciated)
the first script is checking if player has the game pass then cloning the particle effect and putting it in the humanoid root part
local PE = game.ServerStorage:WaitForChild("StarEffect")
local mps = game:GetService("MarketplaceService")
local gamepass_id = 131353745
local plrs = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Char)
if mps:UserOwnsGamePassAsync(player.UserId , gamepass_id) then
wait(2)
local HRP = Char:FindFirstChild("HumanoidRootPart")
local PEC = PE:Clone()
PEC.Parent = HRP
end
end)
end)
Then the button to turn the effects off loops through players then turns enabled to off
local TrailButton = script.Parent
TrailButton.MouseButton1Click:Connect(function()
for _,player in ipairs(game.Players:GetPlayers()) do
local char = player.Character
local HRP = char:FindFirstChild("HumanoidRootPart")
local PE = HRP:FindFirstChild("StarEffect")
PE.Enabled = not PE.Enabled
end
end)
Make a value inside of a player, a bool value. set the bool value to false if player does not want trail or true if player does want trail. THEN when a character is added check the players bool value to see if its false or true
The particles are still coming back, It puts a bool value in the player and when I click the effect button it sets the bool value to false and disables the particles but when I reset the particles re-enable even know the bool value is false, so I think I did something wrong this is what I changed.
First Script
local PE = game.ServerStorage:WaitForChild("StarEffect")
local mps = game:GetService("MarketplaceService")
local gamepass_id = 131353745
local plrs = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
local Effect = Instance.new("BoolValue", player)
Effect.Name = "ParticleEffects"
Effect.Value = true
player.CharacterAdded:Connect(function(Char)
if mps:UserOwnsGamePassAsync(player.UserId , gamepass_id) then
wait(2)
local HRP = Char:FindFirstChild("HumanoidRootPart")
local PEC = PE:Clone()
PEC.Parent = HRP
if Effect.Value == false then PEC.Enabled = false
end
end
end)
end)
Second Script
local TrailButton = script.Parent
TrailButton.MouseButton1Click:Connect(function()
for _,player in ipairs(game.Players:GetPlayers()) do
local char = player.Character
local HRP = char:FindFirstChild("HumanoidRootPart")
local PE = HRP:FindFirstChild("StarEffect")
local Effect = player:FindFirstChild("ParticleEffects")
Effect.Value = not Effect.Value
if Effect.Value == false then PE.Enabled = false
if Effect.Value == true then PE.Enabled = true
end
end
end
end)
Try printing the effect value so we can see whats happening to the values in scripts. And i think it could be that it wont work when its inside playeradded, you need to add the particels and find the effect value another way
Make a remote function when the player wants to switch it off, in another script get the remotefunction and turn the values off in the player and the particles off