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 7 years ago
Edited 7 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?

local WLevel = 1 -- testing to see if it works..
local character = game.Workspace.Player
local player = game.Players:GetPlayerFromCharacter(character)
local lvl1 = game.StarterGui.wantedlevel.lv1
local lvl2 = game.StarterGui.wantedlevel.lv2
local lvl3 = game.StarterGui.wantedlevel.lv3
local lvl4 = game.StarterGui.wantedlevel.lv4
local lvl5 = game.StarterGui.wantedlevel.lv5

if WLevel == 1
    then Instance.new("Cop", workspace)
    and lvl1.visible = true
    and workspace.Cop.Torso.Position = Vector3.new(player.Position)
    else lvl1.visible = false

end

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 — 7y
0
Accept my answer Void_Frost 571 — 6y

2 answers

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

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

local WLevel = 1 -- testing to see if it works..
local character = game.Workspace.Player
local player = game.Players:GetPlayerFromCharacter(character)
local lvl1 = game.StarterGui.wantedlevel.lv1
local lvl2 = game.StarterGui.wantedlevel.lv2
local lvl3 = game.StarterGui.wantedlevel.lv3
local lvl4 = game.StarterGui.wantedlevel.lv4
local lvl5 = game.StarterGui.wantedlevel.lv5

if WLevel == 1 then
    Instance.new("Cop", workspace)
    lvl1.Visible = true
    workspace.Cop.Torso.Position = Vector3.new(player.Position)
else
    lvl1.Visible = false
end
0
thank you the syntax difference of lua and python (the lang im used too) is huge dave8520 0 — 7y
0
What? I know a bit of python, and that is not python. jamesarsenault 192 — 7y
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 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
wait(0.1)
local WLevel = 1 -- testing to see if it works..
local character = game.Players.LocalPlayer.Character
local player = game.Players:GetPlayerFromCharacter(character)
local lvl1 = game.StarterGui.wantedlevel.lv1
local lvl2 = game.StarterGui.wantedlevel.lv2
local lvl3 = game.StarterGui.wantedlevel.lv3
local lvl4 = game.StarterGui.wantedlevel.lv4
local lvl5 = game.StarterGui.wantedlevel.lv5

if WLevel == 1
    then Instance.new("Cop", workspace)
  lvl1.visible = true
workspace.Cop.Torso.Position = Vector3.new(player.Position)
    else lvl1.visible = false

end

This should work...

Answer this question