So this script was designed to function when the gui button is clicked (working) The player's torso is anchored until the player clicks the button (working) After the player clicks the gui button, a part is created, and positioned (working) When the player steps on the part created, a part is supposed to clone into the workspace, supposed to be anchored, and positioned (NOT WORKING)
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) wait(.3) g.Text = player.Name..", Step on the gray square behind you to begin tutorial!" wait() player.Character.Torso.Anchored = false end) function onTouched(part) tutorial.OnTouched:connect(part) local clone = Lighting.Sofa:Clone() clone.Parent = workspace clone.Name = sofa1 sofa1:MoveTo(Vector3.new(3.301, 0.7, 36.088)) --Models don't have position. To move a model use :MoveTo(Vector3.new()) end
The thing is everything works up until the object from lighting is supposed to be cloned. I think the problem is on line 23 tutorial.OnTouched:connect(part)
I don't know how to fix it, I want the parts to clone from workspace when that part is touched.
Line 23 should not be tutorial.OnTouched:connect(part)
part is not the name of your function, onTouched is. part is whatever touched the tutorial. Plus you seem to not understand or at least confused yourself with connecting.
This is how line 23 should actually appear:
tutorial.Touched:connect(onTouched)
I'm not sure of your hierarchy and how it's placed so if this does not work, check it your hierarchy.
So your code should look like this:
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) wait(.3) 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 sofa1:MoveTo(Vector3.new(3.301, 0.7, 36.088)) --Models don't have position. To move a model use :MoveTo(Vector3.new()) end tutorial.Touched:connect(onTouched) -- This is how I see this way of making a function usually lain out. Now, maybe having this at 23 will still work, I'm not sure; you can test.