Remote event not working

Hey, I am having a bug with my boat system. So this is literally the same exact script but with different values, and it works for the small boat. But not for the big boat, the remoteevent doesn’t get called by the server. I have no idea how.

Client code:

local player = game.Players.LocalPlayer
local stats = player:WaitForChild("Stats")

script.Parent.MouseButton1Click:Connect(function()
	if stats.Jenny.Value >= 2000 then
		script.Parent.Parent:WaitForChild("RemoteEvent"):FireServer("Big Boat")
		script.Parent.Parent.Parent:Destroy()
	else
		script.Parent.Parent.Parent.Info.Cost.Text = "Not enough money!"
		wait(1)
		script.Parent.Parent.Parent:Destroy()
	end

end)

Server code:

script.Parent.OnServerEvent:Connect(function(player,action)
	local jenny = player:WaitForChild("Stats").Jenny
	local smallBoat = game.ReplicatedStorage:WaitForChild("SmallBoat"):Clone()
	local bigBoat = game.ReplicatedStorage:WaitForChild("BigBoat"):Clone()

	local prevBoat = game.Workspace:WaitForChild("Boats"):FindFirstChild(player.Name.."'s boat")
	
	if prevBoat then
		prevBoat:Destroy()
	end

	if action == "Small Boat" then
		if jenny.Value >= 500 then
			jenny.Value -= 500



			smallBoat.Name = player.Name.."'s boat"
			smallBoat:SetPrimaryPartCFrame(workspace.Boats["Small boat Spawn"].CFrame)
			smallBoat.Parent = workspace.Boats
		elseif action == "Big Boat" then
			print("Event called")
			if jenny.Value >= 2000 then
				jenny.Value -= 2000
				print("Boat found")


				bigBoat.Name = player.Name.."'s boat"
				bigBoat:SetPrimaryPartCFrame(workspace.Boats["Big boat Spawn"].CFrame)
				bigBoat.Parent = workspace.Boats
				print("boat spawned")
			end
		end
	end
end)

You never ended the if here, so your “elseif” for the big boat is an “elseif” for the value.

1 Like