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

can't change frame or imagelabel's visibility to true what am i doing wrong?

Asked by 8 years ago
Edited 8 years ago

hi i am making a gta style game and im making the wanted level system (localscript if it shouldnt be let me know..) and i put it in StarterPlayerScripts but it doesnt change the visibility to true... what went wrong?

01local WLevel = 1 -- testing to see if it works..
02local character = game.Workspace.Player
03local player = game.Players:GetPlayerFromCharacter(character)
04local lvl1 = game.StarterGui.wantedlevel.lv1
05local lvl2 = game.StarterGui.wantedlevel.lv2
06local lvl3 = game.StarterGui.wantedlevel.lv3
07local lvl4 = game.StarterGui.wantedlevel.lv4
08local lvl5 = game.StarterGui.wantedlevel.lv5
09 
10if WLevel == 1
11    then Instance.new("Cop", workspace)
12    and lvl1.visible = true
13    and workspace.Cop.Torso.Position = Vector3.new(player.Position)
14    else lvl1.visible = false
15 
16end

edit forgot to mention its for a HUD

0
I think you should read a bit about http://wiki.roblox.com/index.php?title=Conditional_statement Tesouro 407 — 8y
0
Accept my answer Void_Frost 571 — 7y

2 answers

Log in to vote
0
Answered by
HLVM 27
8 years ago

You dont use 'And' like that. Try this:

01local WLevel = 1 -- testing to see if it works..
02local character = game.Workspace.Player
03local player = game.Players:GetPlayerFromCharacter(character)
04local lvl1 = game.StarterGui.wantedlevel.lv1
05local lvl2 = game.StarterGui.wantedlevel.lv2
06local lvl3 = game.StarterGui.wantedlevel.lv3
07local lvl4 = game.StarterGui.wantedlevel.lv4
08local lvl5 = game.StarterGui.wantedlevel.lv5
09 
10if WLevel == 1 then
11    Instance.new("Cop", workspace)
12    lvl1.Visible = true
13    workspace.Cop.Torso.Position = Vector3.new(player.Position)
14else
15    lvl1.Visible = false
16end
0
thank you the syntax difference of lua and python (the lang im used too) is huge dave8520 0 — 8y
0
What? I know a bit of python, and that is not python. jamesarsenault 192 — 8y
0
The error here was you didn't correct the part where it tries to get the character form game.Workspace.Player, it would have to be the local player's character. Void_Frost 571 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
01wait(0.1)
02local WLevel = 1 -- testing to see if it works..
03local character = game.Players.LocalPlayer.Character
04local player = game.Players:GetPlayerFromCharacter(character)
05local lvl1 = game.StarterGui.wantedlevel.lv1
06local lvl2 = game.StarterGui.wantedlevel.lv2
07local lvl3 = game.StarterGui.wantedlevel.lv3
08local lvl4 = game.StarterGui.wantedlevel.lv4
09local lvl5 = game.StarterGui.wantedlevel.lv5
10 
11if WLevel == 1
12    then Instance.new("Cop", workspace)
13  lvl1.visible = true
14workspace.Cop.Torso.Position = Vector3.new(player.Position)
15    else lvl1.visible = false
16 
17end

This should work...

Answer this question