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

:Play() Is not a valid member of workspace?

Asked by 4 years ago
Edited 4 years ago
local function OnClick(player)
        local TweenService = game:GetService("TweenService")
 script.Parent.Parent:Play()
local part = script.Parent
part.Position = Vector3.new(-8.95, 6.7, 2.35)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace

local goal = {}
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
local PeePee = part.Position(-0.65, 6.7, 2.35)


if PeePee == true then
        goal.Position = Vector3.new(-8.95, 6.7, 2.35)
    end


if PeePee == false then 
            goal.Position = Vector3.new(-0.65, 6.7, 2.35)
goal.Color = Color3.new(0, 1, 0) 

end
tween:Play()
end





script.Parent.ClickDetector.MouseClick:connect(OnClick)

**Okay so my script is the one above ^

and basically... Im trying to make a door animation, and if its already at position -0.65 6.7 2.35 then it'll tween back to the previous position. but it keep saying :play is not a valid member of workspace, please help.

0
First, use the code block thingy please. It's harder to read without it. niroqeo 123 — 4y
0
Also, you don't need the "do" in if statements. They're for for loops. niroqeo 123 — 4y
0
Ok I did it XUnicorn_SprinklesX -8 — 4y
0
What is script.Parent.Parent and why are you trying to play it royaltoe 5144 — 4y
0
script.Parent.Parent is likely the Workspace service that you're attempting to call Play() from. Play() is a function custom to Tweens, AnimationTrack and Sound instances. You can create a tween using the TweenService and play that tween, if that is what you're trying to do. DeceptiveCaster 3761 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Line 3. I don't know what you are trying to play, but given that script.Parent is a part, and the error is that workspace does not have function Play. script.Parent.Parent must be the workspace the script is referencing. Try removing the line or commenting it.

Ad
Log in to vote
0
Answered by 4 years ago

You have to define what the tween does, look at the tween docs, you dont play the object you are trying to move, you have to define what the tween does and you play that. Look at the tweenservice docs for help, or watch alvinblox videos.

Answer this question