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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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

0
Like : for i = 1, #allowed do ? djstijn321 6 — 4y
0
or can I also just remove the [i] ? djstijn321 6 — 4y
0
A for loop like you said will do just fine User#834 0 — 4y
Ad

Answer this question