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

Why am I getting this preposterous error?

Asked by 10 years ago
Song={L,L,L,L,L,L,R,U} --The Array
CS=c.CurrentSong.Value  --StringValue
-------------------------------
function SongA1()
CS="Song1"
local S1=script.Song1
S1:Play()
for s=1,8 do
Song[s]()
   s=s+1
if s==8 then S1:Stop()elseif
s==7 then wait(0.5) else wait(1)
end end end 

LK=c.Lanes.LeftLane("Key"..CS..(CS[s])) --This is where the error arrives

function L()
L1=Instance.new("ImageLabel",c.Lanes.LeftLane)
L1.Size=UDim2.new(1,0 ,0.2,0)
L1.Position=UDim2.new(0, 0,1,0)
L1.Name=("Key"..CS(CS[s])) -- so when L is called , name is supposed to change
L1.ZIndex=2
L1:TweenPosition(UDim2.new(0,0,0.2,0))  

end

Error = Players.Player.PlayerGui.LocalPricklyMagpie:127: attempt to concatenate field '?' (a nil value)

I'm trying to make the name of L1 change to Song[s] (the Array). s being 1-8 . There are different Songs such as Song1 Song 2 and Song3, so the first CS is suppose to find which song is being played

function SongA1()
CS="Song1"

starting function SongA1 defines what CS (the String Value) is. so for Song1 it should be ("Key".."Song1"..(CS[s]).The Final CS is suppose to get the current Array number that is being called example Song1[2] That would be "L". So the final name should be ("Key".."Song1".."L") and in the Explorer it should look like "KeySong1L".

--I have been trying to fix it for hours and I've decided to post it on here. Thanks in Advance Novice Scripter(SamDomino)

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

The problem is that 's' is nil, because it was the iterator value of your for loop on line 8, which was local to your SongA1 function. Also, on line 2 when you define 'CS' then i'm not sure if you're setting the variable to the stringvalue's value to try and set it later on, but if you are then that's going to cause an error as well, you can't set a variable to a property and attempt to change it, it becomes a read-only variable. I don't really get the point of your entire script and i'm almost certain you're overcomplicating whatever you're trying to do but I hope you can revise it with the knowledge of these errors.

0
Thank you. I will try to simplify it. SamDomino 65 — 10y
Ad

Answer this question