Script deletes player instead of model!

I am making a game where there are procedurally generated obbys with lucky blocks. I want the lucky blocks to be Luckyblock:Destroy() when I touch them, but instead, they delete the player!

the local script to detect when player touches the lucky block (there are 4 blocks)

local player = game.Players.LocalPlayer
local luckyblockevent = game.ReplicatedStorage.LuckyBlockEvent

local luckyblock1 = workspace:WaitForChild("lb" .. 1)
local luckyblock2 = workspace:WaitForChild("lb" .. 2)
local luckyblock3 = workspace:WaitForChild("lb" .. 3)
local luckyblock4 = workspace:WaitForChild("lb" .. 4)

luckyblock1.Touched:Connect(function()
	luckyblockevent:FireServer(luckyblock1)
end)

luckyblock2.Touched:Connect(function()
	luckyblockevent:FireServer(luckyblock2)
end)

luckyblock3.Touched:Connect(function()
	luckyblockevent:FireServer(luckyblock3)
end)

luckyblock4.Touched:Connect(function()
	luckyblockevent:FireServer(luckyblock4)
end)

the script that deletes the lucky luckyblock:

local luckyblockevent = game.ReplicatedStorage.LuckyBlockEvent

luckyblockevent.OnServerEvent:Connect(function(luckyblock)
	luckyblock:Destroy()
end)

On the server script, the first argument is always the player, which is why it’s deleting it. Also make sure to add checks because this remote event can be easily exploited.

1 Like

As @epic_tank mentioned the first parameter is always player when your using OnServerEvent for your remote event then the additional parameters are your data that you want.