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

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

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)

2 comments

0

What line is the error on?

0

Solved.

1 answer

✓ Accepted answer

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

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