My button doesn't seem to work

Hello developers, I was making my spawn button where you type on the TextBox and click the button, but It doesn’t seem to work.

LocalScript:

local Spawn_Entities = game.ReplicatedStorage.Spawn_Entities
local Commands = script.Parent.Scroll.Commands

local SpawnCmd = Commands.SpawnBox

local Entities = {
	"A-24",
	"A-43",
	"A-60",
	"A-74",
	"A-100",
	"A-125",
	"A-150",
	"A-175",
	"A-200",
	"A-255",
	"A-270",
	"A-300",
	"A-330",
	"A-360",
	"A-380"
}

SpawnCmd.Spawn.MouseButton1Click:Connect(function()
	for i, v in pairs(Entities) do
		if SpawnCmd.Text == v then
			Spawn_Entities:FireServer(v)
		end
	end
end)

ServerScript:

local Entities = game.ServerStorage.Entities
local Spawn_Entities =  game.ReplicatedStorage.Spawn_Entities

Spawn_Entities.OnServerEvent:Connect(function(entity)
	local entity = Entities:FindFirstChild(entity)
	if entity then
		local clone = entity:Clone()
		clone.Parent = workspace.SpawnedEntities
	end
end)
1 Like

The first parameter of OnServerEvent is the player that fired the RemoteEvent. Try replacing:

Spawn_Entities.OnServerEvent:Connect(function(entity)

with:

Spawn_Entities.OnServerEvent:Connect(function(player, entity)
1 Like

It works now, thanks. :relaxed:

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.