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

Why this script doesn't position the part?

why this doesn't position the part after i click the textbutton..? it only clones and then i have to click the textbutton again to make the position thing work. It prints out 1 on first click so i know it goes to every line... but still it doesn't position the part.. only when i click the textbutton again

local a = game.ReplicatedStorage.Classic:WaitForChild("ClassicGW")
script.Parent.MouseButton1Click:connect(function()
		if a ~= nil then
		a:clone().Parent = game.Workspace
		a.Position = player.Character["Right Leg"].Position + Vector3.new(0, 0, 5)
		print("1")	
		end
end)

2 comments

1

What does the output say? Any error messages?

0

No errors...

2 answers

✓ Accepted answer

You don't set the position of the cloned part. You change the position of the part in replicatedStorage.

You also don't need the if a ~= nil then, as you waitForChild on it. (Could even be simplified to if a then)

I Suppose player is defined elsewhere in your script.

local a = game.ReplicatedStorage.Classic:WaitForChild("ClassicGW")
script.Parent.MouseButton1Click:Connect(function()
	b= a:Clone()
	b.Parent = workspace
	b.Position = player.Character["Right Leg"].Position + Vector3.new(0, 0, 5)        
end)

I'm guessing a is a part in ReplicatedStorage if so shouldn't you take a out of ReplicatedStorage before Positioning it

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