Can anyone help me with my script

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 made a script that when you activated the tool the value of the invVaule is supposed to change but it’s not working even tho there is no errors shown when i run it.

Here are the codes:

local book = script.Parent
local iq = book.Value

local function onMouseClick()
local player = game.Players.LocalPlayer
local IQ = iq.Value
IQ = tostring(IQ + 5)
local iqbar = game.StarterGui.ScreenGui.IQ_bar
local text = iqbar.Text

iq.Changed:Connect(function()
	text = IQ
end)



print('all stages passed')

end
book.Activated:Connect(onMouseClick)

here is the screenshot when the tool is activated

as you can see in the output window , the “all stages passed” is printed but the value of the intValue never gone up.

is there any ways to make it work?

2 Likes

my guy make when you activate a tool it changes it.

can you show how to do it?

I’m not that experienced with coding

1 Like

Maybe Try This?

local book = script.Parent
local iq = book.Value
local PlayerMouse = game.Players.LocalPlayer:GetMouse()

PlayerMouse.Button1Down:Connect(function()
	local Player = game.Players.LocalPlayer
	local IQ = iq.Value
	IQ = tostring(IQ + 5)
	local iqbar = game.StarterGui.ScreenGui.IQ_bar
	local text = iqbar.Text
	iq.Changed:Connect(function()
		text = IQ
	end)
end)

print('all stages passed')

still not working is it because i put the script into local script?

Maybe doing it like this should make it go up

for index, Tool in PlrInv do
	if Tool:IsA("Tool") then
		Tool.Activated:Connect(function()
			print(Tool.Name .. "Was activated")
			IQ = iq.Value + 0 -- Change this value!
		end)
	end
end
2 Likes

I’m getting an error for unknown PlrInv

oh wait add this at the top of your script

local PlrInv = Players.LocalPlayer.Backpack:GetChildren()

I forgot to add that part

it works thanks for the help and sorry for the inconvineince

2 Likes

Well just to be sure I try this

Just a example I did to test lol

local Tool = script.Parent
local IntValue = Tool.Value
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		IntValue.Value += 5
	end
end)

By the way the code you provide does work but it only works on computers

1 Like

Im still kinda new on lua I still need learn Services
I do how to use lua just I need learn services

1 Like

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