Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0
0

Accept my answer

2 answers

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

3 comments

0

thank you the syntax difference of lua and python (the lang im used too) is huge

0

What? I know a bit of python, and that is not python.

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.

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...

This discussion is preserved as it was. New answers, comments, and votes are closed.