Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[PRO Needed] Can anyone check if my script is correct?

I was trying to make a button that if you have enough point and you click the button, it will teleport you to the part. But it keeps giving me error like "Player is not a valid member of DataModel" What can I do to fix this? Someone Help!

script.Parent.MouseButton1Click:connect(function()
if game.Player.leaderstats.LifeFormFound.Value >= 4 then 	
 game.Players.LocalPlayer.character.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
print('Successful')
else print('Fail')
end
end)

Someone Please Help!

8 comments

0

Is the script a localscript?

0

a script

0

Ok

0

can you write the answer please, thx

0

d0ne

0

If it is correct , mark my answer as correct.

0

ok

0

Please properly indent your code as it makes it easy to read and debug.

1 answer

✓ Accepted answer

Make a it a local script , LocalPlayer can't be used by a normal Script. Also You have to use cap at C of connect , Because connect is deprecated , And can be deleted soon by roblox. Here the source for local script.

script.Parent.MouseButton1Click:Connect(function()
	if game.Players.LocalPlayer.leaderstats.LifeFormFound.Value >= 4 then   
	 game.Players.LocalPlayer.Character.LowerTorso.CFrame = CFrame.new(workspace.Point.Position)
	print('Successful')
	else print('Fail')
	end
	end)

2 comments

0

What's a normal script?

0

Please properly indent your code as it makes it easy to read and debug.

This discussion is preserved as it was. New answers, comments, and votes are closed.