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
7 years ago
01function hello(mode)
02    if mode == "Retract" then
03        game.Workspace.RoadBlock.PopOne.Transparency = 1
04        game.Workspace.RoadBlock.PopTwo.Transparency = 1
05        game.Workspace.RoadBlock.PopThree.Transparency = 1
06        game.Workspace.RoadBlock.PopFour.Transparency = 1
07        game.Workspace.RoadBlock.PopFive.Transparency = 1
08        game.Workspace.RoadBlock.PopSix.Transparency = 1
09        game.Workspace.RoadBlock.PopOne.CanCollide = false
10        game.Workspace.RoadBlock.PopTwo.CanCollide = false
11        game.Workspace.RoadBlock.PopThree.CanCollide = false
12        game.Workspace.RoadBlock.PopFour.CanCollide = false
13        game.Workspace.RoadBlock.PopFive.CanCollide = false
14        game.Workspace.RoadBlock.PopSix.CanCollide = false
15    elseif mode == "Deploy" then
View all 31 lines...

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.

1game.ReplicatedStorage.Bollards:FireServer("Deploy")
2game.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 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
01game.ReplicatedStorage.Bollards.OnServerEvent:Connect(function(player, mode) -- first argument on `OnServerEvent`'s are always the player that fired the server
02for k, v in ipairs(workspace.RoadBlock:GetChildren()) do -- shorten your script by using a for loop instead
03        if mode == "Retract" then
04        v.Transparency = 1
05        v.CanCollide = false
06    elseif mode == "Deploy" then
07            v.Transparency = 0
08        v.CanCollide = true
09        end
10        end
11end
1
Nope. its fired from a localscript. Testing. Robin5D 186 — 7y
Ad

Answer this question