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

Expected identifier when parsing expression, got 'then'?

Asked by
3wdo 198
4 years ago

so like my last post i am trying to make a game tips and tricks menu where if you walk near a object, it will show a gui. when you touch an invinsible brick, if will show the menu but i want it to close when you are not touching it. here is my script

script.Parent.Touched:Connect(function(hit)
    local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
    if Player then
        Player:WaitForChild('PlayerGui'):WaitForChild('Tips').Enabled = true
elseif

    player.PlayerGui.Tips.Enabled = false
    end
end)
0
check my edit 6zk8 95 — 4y
0
edited again 6zk8 95 — 4y

1 answer

Log in to vote
0
Answered by
6zk8 95
4 years ago
Edited 4 years ago

Elseif is followed by another argument, therefore you should replace it with else.

script.Parent.Touched:Connect(function(hit)
    local Pl = hit.Parent.Name
    local player = game.Players:WaitForChild(Pl)
    if player then
        player:WaitForChild('PlayerGui'):WaitForChild('Tips').Visible = true
    else
        player:WaitForChild('PlayerGui'):WaitForChild('Tips').Visible = false
   end
end)
0
thanks but it says attempt to index nil with 'PlayerGui' 3wdo 198 — 4y
0
Edited 6zk8 95 — 4y
0
I write in the same time. Only 2 seconds different GuerraReturns 122 — 4y
0
We have write* GuerraReturns 122 — 4y
View all comments (21 more)
0
it says GetService is not a valid member of Workspace 3wdo 198 — 4y
0
edited again 6zk8 95 — 4y
0
and again 6zk8 95 — 4y
0
the problem is the player, after the else GuerraReturns 122 — 4y
0
edited again xd 6zk8 95 — 4y
0
thanks but it still wont work 3wdo 198 — 4y
0
it says infinite yield possible from the waitforchild 3wdo 198 — 4y
0
LOL, i got the name from the workspace then used tostring() to get it from Players lol xd 6zk8 95 — 4y
0
ion that case, is StarterGui. GuerraReturns 122 — 4y
0
No, its never startergui 6zk8 95 — 4y
0
Yeah, i confuse, sorry. Btw, u have write local player with the tostring and "If Player" <- remove the P GuerraReturns 122 — 4y
0
EDITED!!!!!! IT MIGHT WORK NOW!!!!! 6zk8 95 — 4y
0
^^ 6zk8 95 — 4y
0
xD can't work!! you have write " local player" with a little "p" and after "if Player then" with a P GuerraReturns 122 — 4y
0
Ok yeah xD GuerraReturns 122 — 4y
0
i edited it 6zk8 95 — 4y
0
it says infinite yield but the gui turns on but the thing is it wont turn off after you walk away 3wdo 198 — 4y
0
wait 6zk8 95 — 4y
0
its not going to work sorry 6zk8 95 — 4y
0
i just checked what you wan tto do 6zk8 95 — 4y
0
i had to change visible to enabled and it still wont go away 3wdo 198 — 4y
Ad

Answer this question