Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this function?

Asked by 9 years ago

So I've gotten help from multiple people on this, none of which have gotten past this part.

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

        tut = Instance.new("Part",workspace)

        tut.Name = "tutorial"

        tut.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 to begin tutorial!"
        tut.Anchored = true
    wait(.3)
    player.Character.Torso.Anchored = false        
end)
---------------------------------------------------------------------------------------
function onTouched(part)
local character = part.Parent
local plr = game.Players:GetPlayerFromCharacter( character )

if plr then


local a = Instance.new('Message', workspace)
    player.Character.Torso.Anchored = true
        a.Text = "Tutorial Loading."
    wait(.5)
        a.Text = "Tutorial Loading.."
    wait(.5)
        a.Text = "Tutorial Loading..."

local clon = game.Lighting.Sofa:Clone()
    clon.Parent = game.Workspace
    clon:MoveTo(Vector3.new(3.301, 0.7, 36.088)) --Models don't have position. To move a model use :MoveTo(Vector3.new())
    wait(.2)
player.Character.Torso.Anchored = false
                end
            end
print '4'

 -- 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.


The problem begins at

function onTouched(part)
local character = part.Parent
local plr = game.Players:GetPlayerFromCharacter( character )

if plr then
--rest of script

The problem is, with the part that is created tut = Instance.new("Part", workspace), the rest of the script is supposed to function, like the cloning of the model in Lighting (i know, it should be ReplicatedStorage, but either work).

0
at the bottom of the script add: script.Parent.Touched:connect(onTouched) EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
9 years ago

Here you go!

function onTouched(part)
local character = part.Parent
local plr = game.Players:GetPlayerFromCharacter( character )

if plr then
--rest of script
<OBJECT>.Touched:connect(onTouched)--There we go!
0
opps sorry LordDragon didn't see your Comment. woodengop 1134 — 9y
Ad

Answer this question