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

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

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.

5 comments

0

First, use the code block thingy please. It's harder to read without it.

0

Also, you don't need the "do" in if statements. They're for for loops.

0

Ok I did it

0

What is script.Parent.Parent and why are you trying to play it

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.

2 answers

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.

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.

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