Roblox teleport player not working

hello so i am making a duel combat system and the teleportation was not working here is my script

local l = script.Parent.Value1.Value -- if the player touch the part a bool value will be its name(as a string) and  if the touch ended it will be nil (as a string) etc

local s = script.Parent.Value2.Value --same function applied here (dont mind about the variable names)

if script.Parent.plr1 == true and script.Parent.plr2 == true then --- when the player touch the part it actually set a bool value to true so if both player are touching the part both bool value will be set true then it will teleport them

wait(0.1)

game.Workspace:FindFirstChild(tostring(l)).HumanoidRootPart.CFrame = CFrame.new(49.05, 1.5, -110.59) -- this is not working

game.Workspace:FindFirstChild(tostring(s)).HumanoidRootPart.CFrame = CFrame.new(8.42, 1.5, -103.83) --this too

end

btw i didnt recieve any errors
i used tostring because it could get errors
if u didnt understand something lemme know
any help are apreciated

1 Like

replace CFrane with CFrame

1 Like

oh my bad thx you for the help

1 Like

however its not still working :confused:

Can you show me the error in “output” ,please ?

actually i didnt receive any errors

Maybe you should use print to show the values of l and s just after the wait to see if they do contain the players your trying to move

1 Like

actually i did that and it sucessfully printed the name

1 Like

i found out the error its at the if statment i should have put the .Value at plr1 and pl2 however the if statement is not working i am confuese right now

you’re only setting the CFrame of the humanoidrootpart. try model:SetPrimaryPartCFrame(CFrame) instead. with the model being the players.

2 Likes

can you give me an example pls

local Character = Player.Character
Character:SetPrimaryPartCFrame(CFrame.new(0,10,0))

This moves the character of a undefined player to 0,10,0.
This function can only be used on models.

game.Workspace:FindFirstChild(tostring(l)):SetPrimaryPartCFrame(CFrame.new(49.05, 1.5, -110.59)) 

game.Workspace:FindFirstChild(tostring(s)):SetPrimaryPartCFrame(CFrame.new(8.42, 1.5, -103.83))
1 Like

oh ok thank you for ur help i apreciate it

literally the if statement is having issue this is making the whole script not working anyone know how to fix it?

Do you have any errors? If so, what are they?

You’re comparing an instance to a boolean.
Just remove the == true and it should be fine.

oh cool it works now i have got this error

Workspace.arena.Sever.Script:12: attempt to index nil with ‘SetPrimaryPartCFrame’

the script may have run faster when the bool value changed how do i fixed that?
everything then breaks :confused: which dont show the error again

if there is no primarypart set, it won’t work because the primarypart is nil.
If the model doesn’t exist, obviously it won’t work.
If you use . instead of : it also won’t work.
I don’t know the real issue here because i can’t see the script, but i think it’s the last one.

When does this run. Is this all in a function?

well it runs when both player are step in a brick then it will teleport them to duel its a duel system like both player should stand on a brick then they get teleported