Value is not a valid member of Script

I’m trying to call a function from another script, but even with correct spelling and a proper script reference, I still get an exception “{Value} is not a valid member of {Script}”

image

  • I tried to log reference script.name to be sure where I am and where I try to call a function.

  • I have watched every YouTube video, but most solutions are about misspelling, which is not the case for me.

  • I have tried changing values, scripts, script types, and script destinations, but still stuck.

Here’s what I have:

  • 1.Player local script ProxymityInteractor, which one after game starts, creating copy to Players.{Player name}.PlayerGui path. After player interact with some ProximityPrompt, that script trying to call some function on one of the scripts in his hierarchy.

  • image

  • image

function PickFlower(promptObject,player)
	local flowerAnimator = promptObject:FindFirstAncestor("InteractiveFlower").FadeAnimation
    --Getting script refference
	print(flowerAnimator.name)
    --Results right script's name
	
	flowerAnimator:flowerOff()
    --ERROR! Trying to call script function 
	wait(flowerAnimator.flowerOffSpeed)
    --if previouse line commented, geting ERROR! Trying to get script variable
end
    1. Object script (local or basic) that acts as a tweener for a 3D model, imitating animation.
  • image

local TweenSerwice = game:WaitForChild("TweenService")

local rootObject = script.Parent:WaitForChild("Model")

local flowerOffSpeed = 1.5 --Value I'm trying to get

local startupAnimationInfo = TweenInfo.new(0.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true)

local startupTween = TweenSerwice:Create(rootObject, startupAnimationInfo, {Size = Vector3.new(1.2,1.2,1.2)})

local fadeAnimationInfo = TweenInfo.new(0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	true)

local fadeTween = TweenSerwice:Create(rootObject, startupAnimationInfo, {Size = Vector3.new(0,0,0)})

function flowerOff() --Function I'm trying to call
	startupTween:Play()
	wait(0.5)
	fadeTween:Play()
end

I would appreciate your opinion and any suggestions you may have.

Also, I feel like using the PlayerGui folder for creating dependencies is not the best approach. Do you know of any better ways to do it? Thank you in advance!

You should change FadeAnimation to a ModuleScript and do this in it

local module = {}
local TweenSerwice = game:WaitForChild("TweenService")

local rootObject = script.Parent:WaitForChild("Model")

local flowerOffSpeed = 1.5 --Value I'm trying to get

local startupAnimationInfo = TweenInfo.new(0.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true)

local startupTween = TweenSerwice:Create(rootObject, startupAnimationInfo, {Size = Vector3.new(1.2,1.2,1.2)})

local fadeAnimationInfo = TweenInfo.new(0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	true)

local fadeTween = TweenSerwice:Create(rootObject, startupAnimationInfo, {Size = Vector3.new(0,0,0)})

function module:flowerOff() --Function I'm trying to call
	startupTween:Play()
	wait(0.5)
	fadeTween:Play()
end

return module
1 Like

T.Y. for reply <3

but… :smiley:
image

Do I need to call function in the other way?

RN going to check what a difference in that script type for a moment.

Oops I forgot to mention, you must refer to the Script like this

local flowerAnimator = require(promptObject:FindFirstAncestor("InteractiveFlower").FadeAnimation)

It should work now

1 Like

Frankenstein Its Alive GIF - Frankenstein Its Alive Happy GIFs

Thank you so much, that’s work <3

I need to go study documentation about WHY? now :smiley:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.