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

Can someone take a look at my script and try to find what's wrong ?

Hi!, So I made a car spawner script for a specefic user id only (I'm just starting to learn scripting)

So the problem is it doesn't work and I don't get anny errors, here's the script :

--Settings.
local inUse = false
local allowed = {69198594}
local players = game:GetService("Players")

script.Parent.Button.ClickDetector.MouseClick:connect(function(player)
        if inUse == false and not game.Workspace:FindFirstChild("car"..player.Name.."1") then
            if allowed[i] == player.UserId then
            inUse = true
            script.Parent.Button.BrickColor = BrickColor.new("Really black")
            local a = game.ServerStorage:FindFirstChild(script.Parent.CarName.Value)
            if a ~= nil then
                local b = a:Clone()
                b.Parent = game.Workspace
                b.Name = "car"..player.Name.."1"
            end
            wait(1)
            script.Parent.Button.BrickColor = BrickColor.new("Navy blue")
            inUse = false
        end
    end
end)

Thanks of you could help me :D

1 answer

✓ Accepted answer

You're missing a loop in the code to loop through all of the allowed players.

It should be in between

if inUse == false and not game.Workspace:FindFirstChild("car"..player.Name.."1") then

and

if allowed[i] == player.UserId then

Because i in this case is nothing

3 comments

0

Like : for i = 1, #allowed do ?

0

or can I also just remove the [i] ?

0

A for loop like you said will do just fine

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