Players.Swappermawe.PlayerGui.Ability.Ability:10: attempt to call a table value

Hello everyone!
So i’ve wrote a script for ball’s ability, but i got error about Players.Swappermawe.PlayerGui.Ability.Ability:10: attempt to call a table value, but i call it row TweenService via this line: game.TweenService:Create(script.Parent.Frame, TweenInfo(1), {Position = UDim2.new(0.047,0,0.755, 0)}):Play()

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 fix that error.

  2. What is the issue? Include screenshots / videos if possible!
    Well here is the whole script:

game.UserInputService.InputBegan:Connect(function(a, b)
	if b == false then
		print(a.KeyCode)
		if a.KeyCode == Enum.KeyCode.E then
			if game.Players.LocalPlayer.leaderstats.Ball.Value == "Cheez" then
				if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
					if game.Players.LocalPlayer.Character:FindFirstChild("Cheez") ~= nil then
						script.Enabled = false
						script.RemoteEvent:FireServer("Cheez")
						game.TweenService:Create(script.Parent.Frame, TweenInfo(1), {Position = UDim2.new(0.047,0,0.755, 0)}):Play()
						game.TweenService:Create(script.Parent.Frame.ImageLabel, TweenInfo(8), {Size = UDim2.new(0, 0,0.203, 0)}):Play()
						wait(9)
						game.TweenService:Create(script.Parent.Frame, TweenInfo(1), {Position = UDim2.new(-1,0,0.755, 0)}):Play()
						wait(1)
						script.Parent.Frame.ImageLabel.Size = UDim2.new(0.797, 0,0.203, 0)
						script.Enabled = true
					end
				end
			end
		end
	end
end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub? No, i did not.

maybe you need to say TweenInfo.new(8) instead of TweenInfo(8)

2 Likes

I DIDNT NOTICE THAT :sob:
thank you

1 Like

ntbr but ur code looks… not ideal

lemme fix how it looks (together with dani’s solution)

local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local Players = game:GetService("Players")
local Player = Players.LocalPlayer

local leaderstats = Player:WaitForChild("leaderstats")
local Ball = leaderstats:WaitForChild("Ball")

local Gui = script.Parent -- assuming the script is a child of a ScreenGui
local Frame = Gui.Frame
local ImageLabel = Frame.ImageLabel
local RemoteEvent = script.RemoteEvent

local detectInput = true -- tells whether to activate the script or not

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	local Character = Player.Character
	
	if gameProcessedEvent == false and detectInput == true and Character ~= nil then
		local keyCode = input.KeyCode
		local Humanoid = Character:FindFirstChildOfClass("Humanoid")
		
		print(keyCode)
		
		if keyCode == Enum.KeyCode.E then
			if Ball.Value == "Cheez" then
				if Humanoid.Health > 0 then
					if Character:FindFirstChild("Cheez") ~= nil then
						detectInput = false
						
						RemoteEvent:FireServer("Cheez")
						TweenService:Create(Frame, TweenInfo.new(1), {Position = UDim2.new(0.047, 0, 0.755, 0)}):Play()
						TweenService:Create(ImageLabel, TweenInfo.new(8), {Size = UDim2.new(0, 0, 0.203, 0)}):Play()
						task.wait(9)
						game.TweenService:Create(Frame, TweenInfo.new(1), {Position = UDim2.new(-1, 0, 0.755, 0)}):Play()
						task.wait(1)
						ImageLabel.Size = UDim2.new(0.797, 0, 0.203, 0)
						
						detectInput = true
					end
				end
			end
		end
	end
end)

though its still ur choice if u want to use this code or not

also keep dani’s answer as the solution

1 Like

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