I’ve made a script that lets a player equip particles if they have Roblox Premium. The bool variable changes and I’ve also made so if the player had them Enabled before they respawned, it would grant them again.
However, I haven’t seen the bigger problem. Every player on the server respawns with particles that are currently enabled by someone… resulting in chaos.
Code (ServerScriptService)
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local particleEmitters = replicatedStorage:WaitForChild("PremiumParticles")
local WindyAura = particleEmitters:WaitForChild("Windy")
local PremiumParts = particleEmitters:WaitForChild("PremiumParts")
local canEquip = false
local isEnabled = false
local wasEquippedBeforeDeath = false
-- Function to give or remove particles based on the enabled state
local function toggleParticles(player, enabled)
local character = player.Character
if character then
local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
if torso then
if enabled then
local windyauraClone = WindyAura:Clone()
windyauraClone.Parent = torso
local premiumpartsClone = PremiumParts:Clone()
premiumpartsClone.Parent = torso
print(player.Name .. " was granted particles.")
else
-- Remove particles
for _, particleEmitter in ipairs(torso:GetChildren()) do
if particleEmitter:IsA("ParticleEmitter") then
if particleEmitter.Name == "Windy" or particleEmitter.Name == "PremiumParts" then
particleEmitter:Destroy()
end
end
end
print(player.Name .. " particles were removed.")
end
end
end
end
-- Function to check if player has Roblox Premium
local function hasPremium(player)
return player.MembershipType == Enum.MembershipType.Premium
end
local function removeLock(player)
local playerGui = player:WaitForChild("PlayerGui")
local evademenugui = playerGui:WaitForChild("evademenugui")
local frame = evademenugui:WaitForChild("ShopFrame")
local auraFramePopup = frame:WaitForChild("AurasPopup")
local auraFrame = auraFramePopup:WaitForChild("Frame")
local premiumAuraButton = auraFrame:WaitForChild("PremiumAura")
local LockButton = premiumAuraButton:WaitForChild("Lock")
if player.MembershipType == Enum.MembershipType.Premium then
LockButton.Visible = false
print("Lock hidden, player meets the requirement.")
else
LockButton.Visible = true
print("Lock visible, player does not meet the requirement.")
end
end
local function updateAuraButton(premiumAuraButton, enabled)
if enabled then
premiumAuraButton.Roundify.ImageColor3 = Color3.new(0.996078, 0.996078, 0.498039) -- Set button color to green
premiumAuraButton.TextColor3 = Color3.new(0.270588, 0.262745, 0.184314)
premiumAuraButton.Text = "Enabled"
else
premiumAuraButton.Roundify.ImageColor3 = Color3.new(0.270588, 0.262745, 0.184314) -- Set button color to red
premiumAuraButton.TextColor3 = Color3.new(0.996078, 0.996078, 0.498039)
premiumAuraButton.Text = "Disabled"
end
end
Players.PlayerAdded:Connect(function(player)
local playerGui = player:WaitForChild("PlayerGui")
local evademenugui = playerGui:WaitForChild("evademenugui")
local frame = evademenugui:WaitForChild("ShopFrame")
local auraFramePopup = frame:WaitForChild("AurasPopup")
local auraFrame = auraFramePopup:WaitForChild("Frame")
local premiumAuraButton = auraFrame:WaitForChild("PremiumAura")
local LockButton = premiumAuraButton:WaitForChild("Lock")
local characterAddedConnection
characterAddedConnection = player.CharacterAdded:Connect(function(character)
if wasEquippedBeforeDeath then
toggleParticles(player, true)
isEnabled = true
else
toggleParticles(player, false)
isEnabled = false
end
end)
local enabledBeforeDeath = hasPremium(player)
updateAuraButton(premiumAuraButton, enabledBeforeDeath)
removeLock(player)
premiumAuraButton.MouseButton1Click:Connect(function()
local enabledNow = hasPremium(player)
if enabledNow and not isEnabled then
toggleParticles(player, true)
isEnabled = true
wasEquippedBeforeDeath = true
else
toggleParticles(player, false)
isEnabled = false
wasEquippedBeforeDeath = false
end
updateAuraButton(premiumAuraButton, isEnabled)
end)
-- Ensure the button is initially disabled
updateAuraButton(premiumAuraButton, false)
end)