Hello! I was scripting a custom error message to appear with a tween, but it gives me an error: Unable to cast value to object
This is the line that has the error
local Tween1 = TweenService:Create(plrgui.tool.Text,TweenInfo1,{TextTransparency = 0})
Here is the full script for context
local PriceModule = require(game.ReplicatedStorage.Modules.ItemPrices)
local TweenService = game:GetService("TweenService")
script.Parent.ProximityPrompt.TriggerEnded:Connect(function(player)
local Item = player.Character:FindFirstChildWhichIsA("Tool") or player.Backpack:FindFirstChildWhichIsA("Tool")
local plrgui = player.PlayerGui:WaitForChild("PlayerInterface")
if Item then
if Item == player.Character:FindFirstChildWhichIsA("Tool") then
plrgui.tool.TextTransparency = 1
end
local Money = game.ReplicatedStorage.Values.Money
Money.Value = Money.Value + PriceModule[Item.Name]
print("sold for "..PriceModule[Item.Name])
Item:Destroy()
plrgui.Money.Text = "money: "..Money.Value
else
plrgui.tool.Text = "You don't have anything to sell"
plrgui.tool.TextColor3 = Color3.new(1, 0.25098, 0.25098)
local TweenInfo1 = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0)
local Tween1 = TweenService:Create(plrgui.tool.Text,TweenInfo1,{TextTransparency = 0})
Tween1:Play()
wait(5.5)
local Tween2 = TweenService:Create(plrgui.tool.Text,TweenInfo1,{TextTransparency = 1})
Tween2:Play()
plrgui.tool.TextColor3 = Color3.new(1,1,1)
end
end)
Thank you so much for reading and have a nice day.