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

What is wrong with my gui button that is supposed to move your character a distance away?

In the following script, you press a gui button and it would move your character, it doesn't seem to work so I tried multiply body parts, here are some examples.

script.Parent.MouseButton1Click:connect(function(idk)
	script.Parent.Parent.Parent.Parent.Character.Head.Cframe = CFrame.new(script.Parent.Parent.Parent.Parent.Character.Head.Position + 0, 100, 0)
end)
script.Parent.MouseButton1Click:connect(function(idk)
	script.Parent.Parent.Parent.Parent.Character.UpperTorso.Cframe = CFrame.new(script.Parent.Parent.Parent.Parent.Character.UpperTorso.Cframe + 0, 100, 0)
end)

and here is the script I used to test if this would somehow work in the first place

script.Parent.MouseButton1Click:connect(function(idk)
	script.Parent.Value.Value = script.Parent.Parent.Parent.Parent.Name
	print ("Hi "..script.Parent.Value.Value.."!")
end)

2 comments

0

First off, when you are adding positions, you have to add them as a vector3 value. In your first block of code, replace "0, 100, 0" with Vector3.new(0, 100, 0) make sense? Also, did the script you used to check and see if it works, actually work?

0

yes

1 answer

✓ Accepted answer

When using CFrame, it is case-sensitive. You put Cframe, in which it should've been CFrame.

Secondly, you're setting the head's CFrame, CFrame isn't a property of the part, it is a property used to change the part as a data value. The Position is the real thing you want to change here.

script.Parent.MouseButton1Click:connect(function(idk) -- first script
    script.Parent.Parent.Parent.Parent.Character.Head.Position
=CFrame.new(script.Parent.Parent.Parent.Parent.Character.Head.Position + 0, 100, 0)
end)

By the way, I recommend using CFrame.new(Vector3.new()) instead also but both still do the same, it's just Vector3 is a proper way of handling xyz coordinates in my opinion.

script.Parent.MouseButton1Click:connect(function(idk) -- first script again
	script.Parent.Parent.Parent.Parent.Character.Head.Position = CFrame.new(Vector3.new(script.Parent.Parent.Parent.Parent.Character.Head.Position + 0, 100, 0))
end)
script.Parent.MouseButton1Click:connect(function(idk) -- second script
    script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position = CFrame.new(Vector3.new(script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position + 0, 100, 0))
end)

If it doesn't work then try these other two scripts:

script.Parent.MouseButton1Click:connect(function(idk) -- first script
	script.Parent.Parent.Parent.Parent.Character.Head.Position = CFrame.new(Vector3.new(script.Parent.Parent.Parent.Parent.Character.Head.Position))
	script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position = script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position + Vector3.new(0, 100, 0)
end)
script.Parent.MouseButton1Click:connect(function(idk) -- second script
    script.Parent.Parent.Parent.Parent.Character.UpperTorso.CFrame = CFrame.new(Vector3.new(script.Parent.Parent.Parent.Parent.Character.UpperTorso.CFrame))
    script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position = script.Parent.Parent.Parent.Parent.Character.UpperTorso.Position + Vector3.new(0, 100, 0)
end)

By the way, you don't have to fill in 'idk', instead you could leave it blank, but this isn't important, just saying.

2 comments

0

Thanks, even though I solved the problem, I'll accept your answer

0

Your most welcome!

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