Hey, im trying to fix this error in my script and i cannot find it, please help me
local RS = game:GetService("ReplicatedStorage") local function createEvent(eventName) local event = game.ReplicatedStorage:FindFirstChild(eventName) if not event then event = Instance.new("RemoteEvent", game.ReplicatedStorage) event.Name = eventName end return event end local buy= createEvent("BuyGCoil") buy.OnServerEvent:Connect(function(player, price) local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points") local item = RS:WaitForChild("Gravity Coil") points.Value = points.Value - price local clone = item:Clone() local SPclone = item:Clone() clone.Parent = player.Backpack SPclone.Parent = player.StarterGear
local RS = game:GetService("ReplicatedStorage") local function createEvent(eventName) local event = game.ReplicatedStorage:FindFirstChild(eventName) if not event then event = Instance.new("RemoteEvent", game.ReplicatedStorage) event.Name = eventName end return event end local buy= createEvent("BuyGCoil") buy.OnServerEvent:Connect(function(player, price) local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points") local item = RS:WaitForChild("Gravity Coil") points.Value = points.Value - price local clone = item:Clone() local SPclone = item:Clone() clone.Parent = player.Backpack SPclone.Parent = player.StarterGear end) --// This
You forgot to close the function with an end)
When you have a function with a remote event as you have above,
buy.OnServerEvent:Connect(function(player,price)
there should be an end at the end of the remote event, because it's technically a function now.
Try this:
buy.OnServerEvent:Connect(function(player, price) local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points") local item = RS:WaitForChild("Gravity Coil") points.Value = points.Value - price local clone = item:Clone() local SPclone = item:Clone() clone.Parent = player.Backpack SPclone.Parent = player.StarterGear end)
Hope this helped and happy coding!