--Thanks to Sleazel for the Structure local Players = game:GetService("Players") local ServerStorage = game:GetService("ServerStorage") local TogglePlate = Instance.new("BindableEvent") local Gruppo = mygroupid local playerThatPurchasedGroup = nil TogglePlate.Name = "TogglePlate" TogglePlate.Parent = ServerStorage justOnce = true -- debounce plateActive = true function Group(hit) if hit.Parent:FindFirstChild("HumanoidRootPart") and plateActive then --only prompt players when plate is active (not hidden(nogruppo) local player = Players:GetPlayerFromCharacter(hit.Parent) if justOnce then justOnce = false if player.UserId > 0 and player:IsInGroup(Gruppo) then print(player.Name .. " รจ nel gruppo dei TPOC.") ServerStorage.Group:Clone().Parent = player.Backpack TogglePlate:Fire("nogruppo") playerThatPurchasedGroup = player end wait(1) justOnce = true end end end script.Parent.Touched:connect(Group) local ServerStorage = game:GetService("ServerStorage") local TogglePlate = ServerStorage:WaitForChild("TogglePlate") local plate = script.Parent local decal = plate.Decal local particles = plate.ParticleEmitter local maialino = plate.ParticleEmitter2 local jeff = plate.ParticleEmitter3 local joystick = plate.ParticleEmitter4 plate.Anchored = true local function OnTogglePlate(action) if action == "nogruppo" then -- disappear the plate plateActive = false plate.Transparency = 1 plate.CanCollide = false particles.Enabled = false decal.Transparency = 1 maialino.Enabled = false jeff.Enabled = false joystick.Enabled = false elseif action == "sigruppo" then -- appear plateActive = true plate.Transparency = 0 plate.CanCollide = true particles.Enabled = true decal.Transparency = 0 maialino.Enabled = true jeff.Enabled = true joystick.Enabled = true end end TogglePlate.Event:Connect(OnTogglePlate) local function OnPlayerRemoving(player) if player == playerThatPurchasedGroup then --player that made the purchase is leaving! playerThatPurchasedGroup = nil --"forget" the player TogglePlate:Fire("sigruppo") -- show the plate end end Players.PlayerRemoving:Connect(OnPlayerRemoving)
Fixed.
Remove this line ->
local TogglePlate = Instance.new("BindableEvent") TogglePlate.Name = "TogglePlate" TogglePlate.Parent = ServerStorage
And change with this ->
local TogglePlate = ServerStorage:WaitForChild("TogglePlate")