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

unexpected symbol near ')' ? need help its for my carspawn

Asked by 4 years ago
Edited 4 years ago

unexpected symbol near ')'

The script is:

local GroupId = 3470849 -- Put the GroupId here
local Cooldown = 2 -- Put the cooldown time here
local GroupRanks = {255,100}
local Players = game:GetService("Players")


script.Parent.MouseButton1Click:Connect(function()

            for i,v in pairs(GroupRanks) do
            if script.Parent.Parent.Purchased.Value == true and
            Players.LocalPlayer:GetRankInGroup(GroupId) == v
            then

        -- Spawn it
        game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
            else

        -- Let them purchase it 
        local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)

        if game.Players.LocalPlayer.leaderstats.Wallet.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
            -- The player has enough Wallet
            game.Players.LocalPlayer.leaderstats.Wallet.Value = game.Players.LocalPlayer.leaderstats.Wallet.Value - PriceOfItem
            for i,v in pairs(GroupRanks) do
            script.Parent.Parent.Purchased.Value = true and
            Players.LocalPlayer:GetRankInGroup(GroupId) == v
            script.Parent.Text = "Spawn"
        end
    end
end)
0
What line is the error on? ForeverBrown 356 — 4y
0
Solved. filipb2004 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You are missing some «end»

script.Parent.MouseButton1Click:Connect(function()
    for i,v in pairs(GroupRanks) do
        if script.Parent.Parent.Purchased.Value == true and Players.LocalPlayer:GetRankInGroup(GroupId) == v then
            -- Spawn it
            game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
        else
            -- Let them purchase it 
            local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)
            if game.Players.LocalPlayer.leaderstats.Wallet.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
                -- The player has enough Wallet
                game.Players.LocalPlayer.leaderstats.Wallet.Value = game.Players.LocalPlayer.leaderstats.Wallet.Value - PriceOfItem
                for i,v in pairs(GroupRanks) do
                    script.Parent.Parent.Purchased.Value = true and
                    Players.LocalPlayer:GetRankInGroup(GroupId) == v
                    script.Parent.Text = "Spawn"
        end
    end
end)

Correct version:

local GroupId = 3470849 -- Put the GroupId here
local Cooldown = 2 -- Put the cooldown time here
local GroupRanks = {255,100}
local Players = game:GetService("Players")


script.Parent.MouseButton1Click:Connect(function()
    for i,v in pairs(GroupRanks) do
        if script.Parent.Parent.Purchased.Value == true and Players.LocalPlayer:GetRankInGroup(GroupId) == v then
            -- Spawn it
            game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
        else
            -- Let them purchase it 
            local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)
            if game.Players.LocalPlayer.leaderstats.Wallet.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
                -- The player has enough Wallet
                game.Players.LocalPlayer.leaderstats.Wallet.Value = game.Players.LocalPlayer.leaderstats.Wallet.Value - PriceOfItem
                for i, v in pairs(GroupRanks) do
                    if Players.LocalPlayer:GetRankInGroup(GroupId) == v then -- You forgot a line here
                        script.Parent.Parent.Purchased.Value = true
                        script.Parent.Text = "Spawn"
                    end
                end
            end
        end
    end
end)

If this does not work return me the error on the output I would correct the error

Ad

Answer this question