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}”
-
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.
-
-
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
-
- Object script (local or basic) that acts as a tweener for a 3D model, imitating animation.
-
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!