Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Who can fix this script? Plate not Disappear!

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

2 comments

0

Can you please tell me what you're trying to do? your script seems perfectly fine

0

@Joshument Sorry for bad english -> When a guy press the Plate and he is in TPOC Group, the plate disappear and give the sword (name: Group). When this guy quit from the game, plate reappear. BUT, in this case, i can take infinite Sword because plate not disappear

1 answer

Fixed.

Remove this line ->

local TogglePlate = Instance.new("BindableEvent")
TogglePlate.Name = "TogglePlate"
TogglePlate.Parent = ServerStorage

And change with this ->

local TogglePlate = ServerStorage:WaitForChild("TogglePlate")

This discussion is preserved as it was. New answers, comments, and votes are closed.