for _, player in game:GetService("Players"):GetPlayers() do
local humanoidRootPart = player.Character.PrimaryPart
if humanoidRootPart and Object then
humanoidRootPart.CFrame = Object.CFrame
end
end
the error has me puzzled since the character and humanoidrootpart do not correspond with each other
game:GetService("ReplicatedStorage").CreateDungeon.OnServerEvent:Connect(function(Object)
TransitionModule.Transition()
task.wait(0.5)
for _, player in game:GetService("Players"):GetPlayers() do
local character = player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart and Object then
humanoidRootPart.CFrame = Object.CFrame
end
end
CreateRoom(1)
task.wait(0.5)
AlreadyRooms:FindFirstChild("Dungeon"..PreviousRoom):Destroy()
TransitionModule.TransitionEnd()
end)
I don’t actually believe that is the problem right here. The error is CFrame is not a valid member of Player “Players.ForgetableLife”, which means the code is trying to get the CFrame of a Player object. The only two times the code tries to get the CFrame of something is with humanoidRootPart and with Object. humanoidRootPart isn’t nil, because then the error would be attempt to index nil with 'CFrame' so that makes me believe Object is the issue. What exactly is Object supposed to be, and what is it actually in the code?
game:GetService("ReplicatedStorage").CreateDungeon.OnServerEvent:Connect(function(Object)
TransitionModule.Transition()
task.wait(0.5)
for _, player in game:GetService("Players"):GetPlayers() do
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart and Object then
humanoidRootPart.CFrame = Object.CFrame
end
end
CreateRoom(1)
task.wait(0.5)
AlreadyRooms:FindFirstChild("Dungeon"..PreviousRoom):Destroy()
TransitionModule.TransitionEnd()
end)
local Character = script.Parent
local Humanoid = Character.Humanoid
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
Humanoid.Touched:Connect(function(hit)
if hit.Name == "Doorway" then
if hit.Parent.CanEnter.Value == true then
game:GetService("ReplicatedStorage").CreateDungeon:FireServer(hit.Parent.TpEnd)
hit.Parent.CanEnter.Value = false
end
end
end)
This is the line which causes the error. The first argument of OnServerEvent will always be the player, and the ones after that will be the actual arguments fired in the event. Right now, the Object variable will be the Player who fired the event. To fix, replace the line with this: