So it’s what you think it is. Get player from a server script. But how could I get player in a server script? My game is a room generation game. So when I touched the primary part, it didn’t work. It only works in rooms 1 - 5. So basically when the room gets generated, it doesn’t work. So my thought is that I should get player. This is the player variable that I have right now game.Players.PlayerAdded
Like this in a ServerScript … or pass it with a remote from a ClientScript …
players.PlayerAdded:Connect(function(player) -- this is the player
player.CharacterAdded:Connect(function(character)
local humanoid=character:WaitForChild("Humanoid")
--humanoid.Died:Connect(function()
--
--end)
end)
end)
PlayerAdded doesn’t work when it’s cloned. It only fires if a player/person joined the game
Because PlayerAdded() only fires when they 1st log into the game…
player.CharacterAdded:Connect(function(character) fires every respawn, as in my script.
Waiting on local humanoid=character:WaitForChild(“Humanoid”) helps make sure they are fully spawned.
No. I mean like this:
The ending didn’t get generated because I didn’t open enough doors for it to generate like this picture.
Honestly I’m a bit lost what your having problems with… Only you understand what you’re saying here; “So when I touched the primary part, it didn’t work. It only works in rooms 1 - 5.”
Example;
players.PlayerAdded:Connect(function(player) -- this is the player
-- only runs once when they log into the game
player.CharacterAdded:Connect(function(character)
-- program never leaves this inner loop until the player logs off
-- so "player" set in the outer loop will remain on every respawn
local humanoid=character:WaitForChild("Humanoid") --fully loaded pause
-- player:clone() here
end)
end)
Touched
--ServerScript
local part = script.Parent
local db = true
part.Touched:Connect(function(hit)
if db and hit.Parent:FindFirstChild("Humanoid") then db = false
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
--
end task.wait(2)
db=true
end
end)
I kinda understand what you’re saying, you can use a childadded/descendant added event since I think new roosm are spawning right? Then you can set up a touched event for each primary part that gets added.
Or a simpler but less organized way is just parenting a server-script to the primary part and doing script.Parent. This might be worse on performance though because server-scripts will be cloned over and over. So lets say 100 rooms are generated, 100 server-scripts.
Basically, this is what I mean.
Nevermind I didn’t need player. I didn’t call FireAllClients. I instead called FireClient.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.