I have a title screen script the manipulates the players camera to be fixed on a part until they press play, HOWEVER, everytime they die, their camera is placed on the part again, so how do i make it only happen when the player joins, which would be the local player
local player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(plr)
if player.UserId == plr.UserId then
--- Code here
end
end)
that doesnt seem to work, i dont think you can check if a player is added via a local script
Maybe you can check if a player joined using RemoteEvents?
im not very used to using remote events, how would i make it work?
Could you explain in a bit more depth on what you want to achieve so I could guide you?
so what i have is a title screen for a game im working on, and i want it so that when the player presses the “play” button, the camera goes to normal and stays like that, however everytime they die, it returns their camera to the part, im trying to fix this by only activating the camera script when the player joined, which didnt work via local script.
Put the title screen into PlayerScripts and then make it so the localscript inside the title screen changes the title screens parent to the LocalPlayer’s PlayerGui. This’ll make it so the title screen will only run once
okay so
in a server script you could do something like:
game.Players.PlayerAdded:Connect(function(plr)
RemoteEvent:FireClient()
end)
Local script
RemoteEvent.OnClientEvent:Connect(function()
-- Enter code here
end)
but then would i have to send any data? such as the players useridd? if so how would i do that?
just do this:
server:
game.Players.PlayerAdded:Connect(function(plr)
RemoteEvent:FireClient(plr.UserId)
end)
local script:
RemoteEvent.OnClientEvent:Connect(function(plr.UserId)
-- Enter Code here
end)
Bruh why you using remote scripts when they aint needed
It’s just one solution out of many, I never said it’s the only one
Fair enough. I guess it just seems like a waste to user server performance for an intro script
i just need the soulution to prevent the script from running every time a player dies, i would rather not use remote events
Put the title screen into PlayerScripts and then make it so the localscript inside the title screen changes the title screens parent to the LocalPlayer’s PlayerGui. This’ll make it so the title screen will only run once
StarterGui.ResetOnSpawn = false
If it is a LocalScript inside of StarterGui, put it in game.StarterPlayer.StarterPlayerScripts.
That is a good solution but then you screw up any other gui’s he may have in that directory
oh i think that might work, lemme try it
Okay then maybe use script.Disabled
game.Players.PlayerAdded:Connect(function(plr)
PlayButton.MouseButton1Click:Connect(function()
game.CameraManipulationScript.Disabled = true
end)
Something like that, just refine it