generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Teleport using Cframe is not functioning correctly. (line 2)

Previous Thread :: Next Thread 
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 02:57 PM
I am writing a simple script that teleports users to the home base (0,0,0), then gives them some points.

Here is the leaderboard:

Here is the button code:

[code]
function onTouched(hit)
hit.Parent.Torso.CFrame = Vector3.new(0,0,0)
hit.leaderstats.Points = hit.leaderstats.Points + 10
end
script.Parent.Touched:connect(onTouched)
[/code]

[code]
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"

local money = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats'
money.Name = "Points" --this is the name you want the leader-stat to be when it shows up in-game.
money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
end)
[/code]
Report Abuse
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 02:59 PM
on the points side, I have seem to got the .Value tag thinger. But tele does not work?
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
25 Mar 2014 03:06 PM
its not vector3 its CFrame.new

plus if you move the toro the character will die
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
25 Mar 2014 03:07 PM
MoveTo()
Report Abuse
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 03:07 PM
Points still do not work :(

Then how do I teleport the user?
Report Abuse
protectiveEBob is not online. protectiveEBob
Joined: 09 Jul 2012
Total Posts: 1297
25 Mar 2014 03:13 PM
if hit.Parent then
player=game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Character:MoveTo(0,0,0)
end
end
Report Abuse
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 03:23 PM
I have:

function onTouched(hit)
hit.leaderstats.Points.Value = hit.leaderstats.Points.Value + 10
if hit.Parent then
player=game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Character:MoveTo(0,0,0)
end
end
end
script.Parent.Touched:connect(onTouched)

And it still does not work? Any ideas?
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
25 Mar 2014 03:28 PM
leaderstats should be a property of player, not character.

Just move the part where you defined player up.

function onTouched(hit)
if hit.Parent:FindFirstChild ('Humanoid') then -- this means it's a character
player=game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 10
hit.Parent:MoveTo(0,0,0)
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 03:45 PM
Gives me 10 points, but if I step on it again, it doesn't give me another 10 points. Also it doesn't teleport.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
25 Mar 2014 03:51 PM
script.Parent.Touched:connect(function(Hit)
Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
Player.Character:MoveTo(0,0,0)
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value +10
end
end)
Report Abuse
Alopek is not online. Alopek
Joined: 05 Jan 2014
Total Posts: 32
25 Mar 2014 05:55 PM
This does not work whatsoever.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Mar 2014 05:57 PM
hit.Parent.Torso.CFrame = CFrame.new(0,0,0)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Mar 2014 06:04 PM
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
hit.Parent:MoveTo(0,0,0)
plr.leaderstats.Points.Value = hit.leaderstats.Points.Value + 10
end
end)



game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"

local money = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats'
money.Name = "Points" --this is the name you want the leader-stat to be when it shows up in-game.
money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
end)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Mar 2014 06:05 PM
Not only should that fix the tele problem, but it should fix a point error
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
25 Mar 2014 06:09 PM
Didnt read any of it but...


:MoveTo(Vector3.new(0,0,0))
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image