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

What is the problem here?

I've attempted to fix and further this script numerous times, and it's just not working out for me. Here's what is supposed to come out of it: A user clicks the gui button, the gui closes, and creates a part into workspace. A hint "message" appears at the top. When a player touches the part that the gui button created, an object from lighting clones into workspace and positions in a spot. the player (who is already anchored at the torso) is unanchored (after clicking the button)

What I have working: A user clicks the gui button, the gui closes [done] creates a part into workspace [done]

What isn't working A hint "message" appears at the top [not done] Player torso is unanchored [not done] When a player touches the part that the gui button created, an object from lighting clones into workspace and positions in a spot [not done]


local player = game.onPlayerAdded
script.Parent.MouseButton1Down:connect(function()
   							 script.Parent.Parent.Visible = false
    		Instance.new("Part",workspace).Name = "tutorial"

tutorial.Position = Vector3.new(3.301, 0.7, 36.088)

	local g = Instance.new("Hint", workspace)
g.Text = player.Name..", Step on the gray square behind you to begin tutorial!"

	wait()
player.Character.Torso.Anchored = false			
	
end)
function onTouched(part)
local clone = Lighting.Sofa:Clone()
clone.Parent = workspace
	clone.Name = sofa1
Position.sofa1 = Vector3.new(3.301, 0.7, 36.088)
end

1 comment

0

And yes, this is in a LocalScript.

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer --You are using a local script so you can use LocalPlayer.
script.Parent.MouseButton1Down:connect(function()
                             script.Parent.Parent.Visible = false
local tutorial = Instance.new("Part",workspace)
tutorial.Name = "tutorial"

tutorial.CFrame = CFrame.new(Vector3.new(3.301, 0.7, 36.088))

    local g = Instance.new("Hint", workspace)
g.Text = player.Name..", Step on the gray square behind you to begin tutorial!"

    wait()
player.Character.Torso.Anchored = false         

end)
function onTouched(part)
local clone = Lighting.Sofa:Clone()
clone.Parent = workspace
    clone.Name = sofa1
clone:MoveTo(Vector3.new(3.301, 0.7, 36.088)) --Models don't have position. To move a model use :MoveTo(Vector3.new())
end
end)

Variables don't change even if the name of what the variable is representing changed. More on Variables.

2 comments

0

Actually, you can get the exact Position of a 'Model' type instance by using the 'GetModelCFrame' method [Model:GetModelCFrame().p], and you can also set it's Position.

0

@Alpha Thanks! I never knew that.

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