Error:attempt to call a Instance value

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to find out why this error is occurring and fix the error
  2. What is the issue? Include screenshots / videos if possible!
    this error is occurring: 17:06:50.195 Players.LolBloxLolxxxx.PlayerScripts.PopupScript:47: attempt to call a Instance value - Client - PopupScript:47
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked online and haven’t found a solution that works
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
player=game.Players.LocalPlayer
tweenService = game:GetService("TweenService")
tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
RS=game.ReplicatedStorage
 moduleSc = require(RS.Abbreviate)
 
ov=player:WaitForChild('OV')
Strength=ov.Strength
Vitality=ov.Vitality
Speed=ov.Vitality
Insights=ov.Insights
Values={
previousInsights = player.OV.Insights.Value,
previousSpeed = player.OV.Speed.Value,
previousVitality = player.OV.Vitality.Value,
previousStrength = player.OV.Strength.Value}
local function Popup(newValue, variable)
	
	Popup=game.ReplicatedStorage.Popups[tostring(variable).."Popup"]:Clone()
	Popup.Parent=player.PlayerGui.ScreenGui
	local previousValue=Values["previous"..variable]
	print(previousValue)
	local textFadeTween = tweenService:Create(Popup, tweenInfo, {TextTransparency = 1})
	
		local variableGained = math.floor(newValue - previousValue)
		if variableGained<0 then
			Popup.Text=variable..moduleSc.abbreviate(variableGained)
		else
		Popup.Text=variable.."+"..moduleSc.abbreviate(variableGained)
		end
		Popup.TextTransparency=0
		Popup.Position=UDim2.new(math.random(300,700)/1000,0,math.random(500,750)/1000,0)
		Popup.Rotation=math.random(-15,15)
		wait(0.35)
		textFadeTween:Play()
		Popup:TweenPosition(
			UDim2.new(Popup.Position.X.Scale,0,Popup.Position.Y.Scale+0.1,0),
			"InOut",
			"Quint",
			0.3)
	
	
	
end
Insights.Changed:Connect(function(number)
	
	Popup(number,"Insights")-- error occurs second time
end)

plz help

This line overwrites the Popup function with an Instance value. Consider making it local:

	local Popup=game.ReplicatedStorage.Popups[tostring(variable).."Popup"]:Clone()
1 Like

To add to this, all variables should be local. I’m sure there is a situation were not making them local is the best/only course of action, but I’ve never had a situation where that is necessary.

2 Likes

thanks for the help! i was thinking of optimizing after i had fully gotten the script to work!