Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Who can fix this script? Plate not Disappear!

Asked by 5 years ago
Edited 5 years ago
--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)
0
Can you please tell me what you're trying to do? your script seems perfectly fine Joshument 110 — 5y
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 GuerraReturns 122 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Fixed.

Remove this line ->

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

And change with this ->

local TogglePlate = ServerStorage:WaitForChild("TogglePlate")
Ad

Answer this question