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

Have bollards for a gate in FE, how would I fix?

Asked by
Robin5D 186
6 years ago
function hello(mode)
    if mode == "Retract" then
        game.Workspace.RoadBlock.PopOne.Transparency = 1
        game.Workspace.RoadBlock.PopTwo.Transparency = 1
        game.Workspace.RoadBlock.PopThree.Transparency = 1
        game.Workspace.RoadBlock.PopFour.Transparency = 1
        game.Workspace.RoadBlock.PopFive.Transparency = 1
        game.Workspace.RoadBlock.PopSix.Transparency = 1
        game.Workspace.RoadBlock.PopOne.CanCollide = false
        game.Workspace.RoadBlock.PopTwo.CanCollide = false
        game.Workspace.RoadBlock.PopThree.CanCollide = false
        game.Workspace.RoadBlock.PopFour.CanCollide = false
        game.Workspace.RoadBlock.PopFive.CanCollide = false
        game.Workspace.RoadBlock.PopSix.CanCollide = false
    elseif mode == "Deploy" then
        game.Workspace.RoadBlock.PopOne.Transparency = 0
        game.Workspace.RoadBlock.PopTwo.Transparency = 0
        game.Workspace.RoadBlock.PopThree.Transparency = 0
        game.Workspace.RoadBlock.PopFour.Transparency = 0
        game.Workspace.RoadBlock.PopFive.Transparency = 0
        game.Workspace.RoadBlock.PopSix.Transparency = 0
        game.Workspace.RoadBlock.PopOne.CanCollide = true
        game.Workspace.RoadBlock.PopTwo.CanCollide = true
        game.Workspace.RoadBlock.PopThree.CanCollide = true
        game.Workspace.RoadBlock.PopFour.CanCollide = true
        game.Workspace.RoadBlock.PopFive.CanCollide = true
        game.Workspace.RoadBlock.PopSix.CanCollide = true
        end
end

game.ReplicatedStorage.Bollards.OnServerEvent:connect(hello)

Tried lots of things, and it didn't work. All of the 'pops' are unions of bollards. Script is in ServerScriptService, remoteevent named Bollards is in replicatedstorage.

Tried firing it.

game.ReplicatedStorage.Bollards:FireServer("Deploy")
game.ReplicatedStorage.Bollards:FireServer("Retract")

Both won't work. Any ideas?

0
You might want to put all of those "PopOne" through "PopSix" in a table so you can just loop through all of them to set the Transparancy and CanCollide properties. And you can at least make a variable for "game.Workspace.RoadBlock". GoldenPhysics 474 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
game.ReplicatedStorage.Bollards.OnServerEvent:Connect(function(player, mode) -- first argument on `OnServerEvent`'s are always the player that fired the server
for k, v in ipairs(workspace.RoadBlock:GetChildren()) do -- shorten your script by using a for loop instead
        if mode == "Retract" then
        v.Transparency = 1
        v.CanCollide = false
    elseif mode == "Deploy" then
            v.Transparency = 0
        v.CanCollide = true
        end
        end
end

1
Nope. its fired from a localscript. Testing. Robin5D 186 — 6y
Ad

Answer this question