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

Why wont this script work?




function Start()

if  script.Parent.Attack.Value.Value == "Laser eye" then
	wait()
	local Laser = game.Lighting.Laser:Clone()
	Laser.Parent = script.Parent
	Laser.Position = script.Parent.Position
	Laser.Part.Position = script.Parent.Position
	print("okkkk")
	game.Debris:AddItem(Laser,.5)
	print("Ok")
end

if  script.Parent.Attack.Value.Value == "Laser Burst" then
	wait(2)
	local Laser = game.Lighting.Laser:Clone()
	Laser.Parent = script.Parent
	Laser.Position = script.Parent.Position
	Laser.Part.Position = script.Parent.Position
	print("okkkk")
	game.Debris:AddItem(Laser,.5)
end
end


skill = {"Laser Eye","Laser Brust"}
script.Parent.Attack.Value.Value = skill[math.random(1,#skill)]
Start()
print("okoooo")


No errors in output. The lay out is Handle/Attack/Value

4 comments

0

You're comparing "Laser eye" to "Laser Eye" and "Laser Brust" to "Laser Burst".

0

No i havent made Laser burst its just for testing. WHta im having problem is when i do Start() the function wont run

1

what he is saying is, in the table for skill{} you have your data spelled incorrectly in relation to the 'if' functions on lines 03 and 14

0

What do you mean can u help me fix? I just started to use tabels so im not a pro at them

1 answer

i just corected your spelling. if it still dont work add print("ok") after game.Debris:AddItem(Laser,.5)


function Start()


if  script.Parent.Attack.Value.Value == "Laser Eye" then
    wait()
    local Laser = game.Lighting.Laser:Clone()
    Laser.Parent = script.Parent
    Laser.Position = script.Parent.Position
    Laser.Part.Position = script.Parent.Position
    print("okkkk")
    game.Debris:AddItem(Laser,.5)
    print("Ok")
end

 
if  script.Parent.Attack.Value.Value == "Laser Burst" then
    wait(2)
    local Laser = game.Lighting.Laser:Clone()
    Laser.Parent = script.Parent
    Laser.Position = script.Parent.Position
    Laser.Part.Position = script.Parent.Position
    print("okkkk")
    game.Debris:AddItem(Laser,.5)
end
end

 

 
skill = {"Laser Eye","Laser Burst"}
script.Parent.Attack.Value.Value = skill[math.random(1,#skill)]
Start()
print("okoooo")

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