https://gyazo.com/e4c5b3455921f286491b3a31ea2142ea Oh boy. So. When the code is like this:
script.Parent.Event.OnServerEvent:connect(function(Player) Sound:Play() PanelSlideTween:Play() end else
"Expected ')' (to close '(' at line 17, got 'else.'" You think closing
script.Parent.Event.OnServerEvent:connect(function(Player))
like this would solve the problem with else, but.. Expected identifier when parsing expression, got ')'
Does anyone know how I could solve this?
Here is the whole script.
local TweenService = game:GetService("TweenService") local Panel = workspace.Door local PanelRoot = Panel.Root local Sound = script.Parent.Part.Sound local PanelSlideInfo = TweenInfo.new() -- Let's use all defaults here local PanelSlideTweenClose = TweenService:Create(PanelRoot, PanelSlideInfo, { CFrame = PanelRoot.CFrame * CFrame.new(PanelRoot.Size.X - 0.1, 0, 0) }) local PanelSlideTween = TweenService:Create(PanelRoot, PanelSlideInfo, { CFrame = PanelRoot.CFrame * CFrame.new(PanelRoot.Size.X + 0.1, 0, 0) }) script.Parent.Event.OnServerEvent:connect(function(Player)) Sound:Play() PanelSlideTween:Play() end else
And the script associated with it that triggers the event.
local inputservice = game:GetService("UserInputService") inputservice.InputBegan:connect(function(i,g) if i.UserInputType == Enum.UserInputType.Keyboard then if i.KeyCode == Enum.KeyCode.E then for _,Door in pairs(workspace.Doors:GetChildren()) do local Mag = (Door.Center.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude if Mag <= Door.Range.Value then Door.Event:FireServer() break end end end end end)
It's easy to forget how to close a :Connect(function()
, you DO NOT use end
, instead you use end)
.
Example:
game.Player.PlayerAdded:Connect(function(plr) -- do stuff end) -- HERE IS WHAT YOU FORGOT
Also remove the else
at the end of your script.
Complete code:
local TweenService = game:GetService("TweenService") local Panel = workspace.Door local PanelRoot = Panel.Root local Sound = script.Parent.Part.Sound local PanelSlideInfo = TweenInfo.new() -- Let's use all defaults here local PanelSlideTweenClose = TweenService:Create(PanelRoot, PanelSlideInfo, { CFrame = PanelRoot.CFrame * CFrame.new(PanelRoot.Size.X - 0.1, 0, 0) }) local PanelSlideTween = TweenService:Create(PanelRoot, PanelSlideInfo, { CFrame = PanelRoot.CFrame * CFrame.new(PanelRoot.Size.X + 0.1, 0, 0) }) script.Parent.Event.OnServerEvent:Connect(function(Player) Sound:Play() PanelSlideTween:Play() end) -- HERE IS WHAT YOU FORGOT -- I DELETED THE else