I need help making scripts client sided

So I’m working on an FPS game and I have a main menu, but you’re able to die while in the main menu which I don’t want. So I currently have a Local Script for the play button that connects to a RemoteEvent which then goes to a Script in ServerScriptService that Destroys the main menu spawn and Clones the map spawns, then when you press M to open the menu again, it Destroys the map spawns and Clones the menu spawn, but this happens for the server, not just the client.

For example, Player 1, 2 and 3 are all playing, Player 1 presses M to open the Menu to change his gun, Player 2 kills Player 3 then Player 3 spawns at the menu spawn instead of the map

I’ve tried just pasting the ServerScriptService code into a Local Script, I tried moving the Local Script to StarterGui too. I’ve tried giving the players a ForceField that lasts until they click play, but I ended up making that server sided instead of client sided too. I’ve tried making a script that when a player joins, they’re teleported to a different location then once they click play, they get reset and spawn on the map but it wouldn’t teleport

My Local Script for the button

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.SpawnEvents.MapSpawnEvent:FireServer()
end)

My Local Script that resets you and changes spawns when you press M

local menuKey = Enum.KeyCode.M

local plr = game.Players.LocalPlayer
local chara = plr.Character or plr.CharacterAdded:Wait()

plr:GetMouse().KeyDown:Connect(function(m)
	if m == "m" then
		
		game.ReplicatedStorage.SpawnEvents.MenuSpawnEvent:FireServer()
		
		wait(1)
		
		game.Players.LocalPlayer.Character.Humanoid.Health = 0
	end
end)

My ServerScriptService Script

local player = game.Players.LocalPlayer

game.ReplicatedStorage.SpawnEvents.MapSpawnEvent.OnServerEvent:Connect(function(player)
	game.ServerStorage.MapSpawns:Clone().Parent = game.Workspace
	game.Workspace.MenuSpawn:Destroy()
end)

game.ReplicatedStorage.SpawnEvents.MenuSpawnEvent.OnServerEvent:Connect(function(player)
	game.ServerStorage.MenuSpawn:Clone().Parent = game.Workspace
	game.Workspace.MapSpawns:Destroy()
end)

Sorry for all the text, I’ve watched countless videos and read through a lot of Forums. If anyone can even link me to a video or Forum that’ll help me out, that’d be amazing.

What I would do is make some sort of holding container to place characters in while in the menu etc. and then when the player opens the menu, teleport them into the holding box, and don’t let them move. When they are done you can just put them back in the map.

As for the map deletion, if you keep still do it how it is currently done, anytime anyone opens the menu it will destroy the map spawns for everyone, not just the single player. I don’t think that that behavior is what you want, so just teleporting the player should work just fine and not cause problems with other players.

I managed to finally get tp’ing to work

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