Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i make a variable change to true or false when left mouse is pressed?

Hi, im trying to make a T-pose animation (like the one in JToH) and i couldn't find how to check for mouse inputs. I'm really new to Lua, but i have some experience with C+ and GML. I could get as far as this:

active = false
script.Parent.Equipped:connect(function()
	active = true
end)
script.Parent.Unequipped:connect(function()
	active = false
end)

(This is on a tool by the way. Sorry for my inexperience, i searched for a long time but this is my last resort.)

1 answer

make a remote event in replicatedstorage, rename it to itemequipped.

normal script in ServerScriptService:

if game.ReplicatedStorage.itemequipped:Fired()
	--do stuff
end

local script in tool:

active = false
script.Parent.Equipped:connect(function()
    active = true
end)
script.Parent.Unequipped:connect(function()
    active = false
end)
if active then
	game.ReplicatedStorage.itemequipped:Fire()
end

btw I might be wrong because I do not do much Fire() so most of this code is guesses but I want to help if I can.

8 comments

0

ye i think it's supposed to be FireServer() instead of just Fire(), also to rubu make sure to disable the "RequireHandle" property on the tool

0

ok, thx I do not know much about fire-ing.

0

I'll try this asap, it looks like it'll work to me. just guessing tho.

0

dont forget to do what caqc said, he knows more then me, I know nothing of this stuff.

0

oh and the serverscript should be game.ReplicatedStorage.itemequipped.OnServerEvent:Connect(function() instead of the if game.ReplicatedStorage.itemequipped:Fired()

0

ok

0

well i give up im not experienced enough to do this

0

I think alvin blox teaches this to

This discussion is preserved as it was. New answers, comments, and votes are closed.