This is a server sided script that is supposed to kill players when they are standing above my baseplate
local ray = Ray.new(workspace.BuildBase.Position,Vector3.new(0,1,0)*500)
local hit, pos = workspace:FindPartOnRay(ray, workspace.BuildBase)
print(hit)
if hit then
local char = hit:FindFirstAncestorOfClass("Model")
local plr = game.Players:GetPlayerFromCharacter(char)
if plr then
char.Humanoid:BreakJoints()
end
end
Do you mean like a large baseplate, that kills anyone above any part of it? Because that code will only kill a player standing above the dead center of the baseplate.
You’ll have to raycast down from each player’s position instead, with a whitelist of {workspace.BuildBase}. If the base is not rotated you could also just check if the player is within the coordinates of the base.
If it’s meant to clear players after a minigame, just track players who aren’t in the lobby by putting them in a table. When the game ends, run through that table and break the joints of their characters.
There are a few ways you can resolve this, and this will kind of act as a summary of what people have said above me:
Don’t rely on location of the player at all:
Keeping track of whether or not a player is in a minigame can be handled with code. If your game teleports players into an arena, you may also want to make a table of all players who you teleported and when the minigame is over you can call something like :LoadCharacter() to respawn the character back in the lobby
If you feel like raycasting is necessary, don’t raycast from the baseplate, as that will only project a ray from the center of the baseplate upwards, which isn’t what you want. Instead, raycast from each player downwards, which will return the baseplate if it is below the player.
If you don’t want the players to touch the baseplate at all, you could use .Touched (the same way you would if a player stepped on lava) and just kill them that way.
I would definitely use option one because it is much more controllable than the other two.