Main Menu Error

You can write your topic however you want, but you need to answer these questions:
To fix a little bug that turn my main menu into a fard machine

  1. What is the issue? Include screenshots / videos if possible!

    please dont take it as a joke, the script dont find a model in serverstorage and just dont works, even since its there, it says " spawnpoints is not a valid member of ServerStorage " and just stay in the menu screen instead of working.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Well, when i try to change something it breaks and the camera goes to the player instead of staying in menu, this is very specific and i didnt found anything in devforum about this.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

  local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local death = game.ReplicatedFirst.DeathEffect

local defaultCframe = camera.CFrame
local view = 150
local blur = game.Lighting.Blur
local col = game.Lighting.ColorCorrection
local menuspawn = game.Workspace.SpawnLocation

blur.Size = 10
death.Disabled = true

function updateCamera()
	camera.CFrame = game.Workspace.MenuCamera.CFrame
end

game:GetService("RunService").RenderStepped:Connect(updateCamera)

script.Parent.Frame.Play.MouseButton1Click:Connect(function()
	wait(0.2)
	game.Workspace.Boom.Playing = true
	menuspawn:Destroy()
	game.ServerStorage.spawnpoints.Parent = workspace  -- The part that gives a error.
	view = 150
	blur.Size = 1
	game.Workspace.DamagePart.Script.Disabled = false
	script.Parent.Frame.Play.TextTransparency = 1
	script.Parent.Frame.TextLabel.TextTransparency = 1
	col.TintColor = Color3.fromRGB(0,0,0)
	camera.CameraType = Enum.CameraType.Fixed
	game.Workspace.MenuMusic:Stop()
	wait(7)
	col.TintColor = Color3.fromRGB(163, 158, 136)
	game.ReplicatedFirst.DeathEffect.Disabled = false
	script.Parent.Frame:Destroy()
	script:Destroy()
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Sorry if the topic is a bit hard to read, its been some time since i last made one.

Localscripts cannot access ServerStorage and ServerScriptService. only normal scripts can.

You could use RemoteEvents when the button has been clicked and fire it, then a script would handle that event and set the spawnpoint parent to workspace

Would that like, affect everyone ? Since its needed to be only for one player , if the player is too far away from the menu scene and they are with low graphic settings it just becomes sky.

Yes, since the RemoteEvent is gonna get handled by a server script, meaning it would create that object to the server and show it to all the players in their screen.

Damn, so i will not be able to use the remote, only one player would get menu to work how its intended to be, imma figure out another way to, what if i put it on another place ? like lightning ?

also could you explain what is going on this line, maybe i could help.

also i may misunderstood your question, when the player who clicked the menu fard button the spawnpoint created in the workspace would not turn into sky for everyone since its created into using serverscrip,t and when any player went near that spawnpoint would appear in their screen.

if the player spawns too far away from the menu scene, and the graphics are on the minimum or another setting depending on the spawn, it will look like nothing with some buildings near your character for another players, the first one that clicked would get stuff normally and play the game, the other ones that join would have that happening, there is a spawnpoints near the menu scene that make so that not happen, its deleted when the button is pressed ( atleast its supposed to )

also when its pressed a damage part script would be enabled for that player that pressed ( thats what i could do since im not big pro gamer god at scripting ) and the player would die and would spawn at the other spawnpoints on the main map

instead of parenting the spawnpoints to workspace, why not teleport the player who clicked the button on
any spawnpoints.

The player far away from menu scene would make the menu scene disappear to due to chunks loading and unloading to avoid lag. if another player join they would still see the menu scene no matter how far the other player on the map.

Teleporting looks like a good idea, but do that would use cframes ? still need to learn how to use them, also, would it be able to tp players to different ones with " or " ?

CFrames are simple to teleport players to a specific locations, basically you get the player’s HumanoidRootPart.CFrame and set it to Spawnpoint.CFrame.

For teleport them to random location, you can use Math.random()
then label the spawnpoints to “Spawnpoint1” to “Spawnpoint10” depending how many spawnpoints in the workspace, now to teleport the player on any of those spawnpoint you just type

local humanoidrootpart = character:WaitForChild("HumanoidRootPart")
humanoidrootpart.CFrame = game.Workspace["Spawnpoint" .. math.random(1,9)].CFrame

If you don’t want to label them between 1 to all spawnpoints, You could use for loops that will check all children in the workspace that has name “Spawnpoint” and teleport the player randomly

1 Like

Imma try it later and see if it works ! If it do well imma show the results here, also i renamed the actual game name and play button to fard due to me thinking that i looked like a masterpiece and would be great to keep as a video , imma change it later.

You can use a remote event. Fire the remote from the client and in the server script you can parent the model to workspace.

Well, tried to do it, or i put it at the wrong place, when i put the local humanoidpart with the another locals , it breaks, when i put it where the button is pressed, it stays the same but give a different error

i may just be dumb as hell.

could you show me your script? make sure its one local script that handling them

you can only put “:Connect” or “:Wait” in RBXScriptSignal (basically like functions) so you can’t put waitforchild there

//
local player = game.Players.LocalPlayer

local character = player.CharacterAdded

local mouse = player:GetMouse()

local camera = workspace.CurrentCamera

local death = game.ReplicatedFirst.DeathEffect

local defaultCframe = camera.CFrame

local view = 150

local blur = game.Lighting.Blur

local col = game.Lighting.ColorCorrection

local menuspawn = game.Workspace.SpawnLocation

blur.Size = 10

death.Disabled = true

function updateCamera()

camera.CFrame = game.Workspace.MenuCamera.CFrame

end

game:GetService(“RunService”).RenderStepped:Connect(updateCamera)

script.Parent.Frame.Play.MouseButton1Click:Connect(function()

wait(0.2)

game.Workspace.Boom.Playing = true

menuspawn:Destroy()

local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)

humanoidrootpart.CFrame = game.Workspace[“Spawnpoint” … math.random(1,4)].CFrame

view = 150

blur.Size = 1

script.Parent.Frame.Play.TextTransparency = 1

script.Parent.Frame.TextLabel.TextTransparency = 1

col.TintColor = Color3.fromRGB(0,0,0)

camera.CameraType = Enum.CameraType.Fixed

game.Workspace.MenuMusic:Stop()

wait(1)

col.TintColor = Color3.fromRGB(163, 158, 136)

game.ReplicatedFirst.DeathEffect.Disabled = false

script.Parent.Frame:Destroy()

script:Destroy()

end)
//
Its only one localscript inside a screengui with a frame with play button and title

Where should i put it then ? When i put it on the locals part it breaks, maybe after death.disabled = true ?

so i found out the problem was the “character variable”,
the characterAdded has no wait function and the other variable.
To fix this change the local character variable to:

local character = player.Character or player.CharacterAdded:Wait()

in this, the variable check if the player.Character exist if not then wait for the character to exist.

also no need to change the localscript location.

1 Like

Worked !

Im very happy, this menu thing was giving me headaches.

1 Like