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 this script?

local button = script.Parent

function onclick()
	--finds spawn--
	local player = script.Parent.Parent.Parent.Parent.Character
	local playerPos = player.Torso.Position
	local g = Instance.new("Part")
	g.Parent = playerPos
	
end
script.Parent.MouseButton1Click:connect(onclick)

i am trying to insert a part where the player is but it just wont work. is there anything that i could change to make it work?

3 comments

0

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

0

it was relevant because there is something wrong in the script so i asked you guys to help me find what is wrong in the script and how can i fix it?

0

Be more exact. A general statement such as the one you used is not exact. Provide more detail. Include what its about, such as MouseButton1Click.

1 answer

✓ Accepted answer

You're setting the parent of g to a position, not an object. If you want to set a part's position, use g.Position not g.Parent

local button = script.Parent

function onclick()
    --finds spawn--
    local player = script.Parent.Parent.Parent.Parent.Character
    local playerPos = player.Torso.Position
    local g = Instance.new("Part")
    g.Parent = player
    g.Position = playerPos -- this
end
script.Parent.MouseButton1Click:connect(onclick)

1 comment

0

oh ok thanks

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