#Mobile Button Help

1 messages · Page 1 of 1 (latest)

shy plume
#

Ok I need help with this, I have a run and walk animation that plays when I click a key, but I made a button so that it also works when you click it, the problem is that I don't know how to make it work. Could anyone help me with this?

#

@tame trench

#

@plain inlet

agile imp
#

^^

shy plume
#

I do have a question

#

Could you help me with that

glad flareBOT
#

studio** You are now Level 2! **studio

shy plume
#

@agile imp

#

So how could I do it

#

Which one do you recommend I do

#

@agile imp

agile imp
#

:p

shy plume
#

Ok ok

shy plume
#

Under

#

The run and walk script

#

?

agile imp
#

umm

#

thats for you to figure out!

#

^^

shy plume
#

They're 2 seperate ones

#

Oh

#

Yeah then i guess I'll have to forget about it

agile imp
#

An object which facilitates asynchronous, one-way communication across the
client-server boundary. Scripts firing a Class.RemoteEvent do not yield.

An object which enables custom events through asynchronous one-way
communication between scripts on the same side of the client-server boundary.
Scripts firing a Class.BindableEvent do not yield.

shy plume
#

Ok I guess this is my last question do I use both

#

Or just 1

agile imp
#

or you can use none!

#

Im assumign your run script is a... localscript?

shy plume
#

Yes

#

So there's a walk and run

agile imp
#

So just reference the button! ^^

shy plume
#

Wdym reference

#

Ok im just confused now

agile imp
#

like
local Variable =

#

im not that good at explaining!

#

sorry!!

shy plume
#

Oh ok

#

It's fine

#

The thing is

#

I have like

#

It's custom animation scripts

#

So I have a walk

#

And a run

#

When I click a key

#

It alternated

#

Alternates

pulsar drum
#

r u saying the one key activates two things

shy plume
#

Between the run or walk

shy plume
pulsar drum
#

and you want to distinguish

shy plume
#

When I click r it stops the custom animation script

pulsar drum
#

between what u want

shy plume
#

For walking

#

I want to replicate that

#

But with a button

#

I mean like

#

When I click the button

#

It does the same thing

pulsar drum
#

oh

shy plume
#

Want me to show you

#

?

pulsar drum
#

ok so basically on pc u want “r” to do something

#

and on mobile a button to do the same thing

shy plume
#

Yes

#

Yes yes exactly

pulsar drum
#

where is the logic for the animation kept in

#

a script or module

shy plume
#

Ok I don't understand that but I'll tell you, the scripts are local scripts inside of startercharacterscripts

pulsar drum
#

ok so like

#

you could technically copy and paste the same walk animation logic into the on event for the button

#

and also when the player presses R

shy plume
#

Btw it also has a resume walk animation script which is just a script

pulsar drum
#

this is how i woukd handle it

#

i would create a function in a module script

shy plume
#

Ok so what do you want me to do

pulsar drum
#

that function will do the animation when called

glad flareBOT
#

studio** You are now Level 1! **studio

shy plume
#

Can you show me step by step

pulsar drum
#

ye

#

i am technically lol

shy plume
#

Oh ok mb

pulsar drum
#

ok so

#

real quick

#

i would make a function in the module script

#

that function would activate the animation

shy plume
#

Where is that

pulsar drum
#

wym that

shy plume
#

Function and module script I don't understand

glad flareBOT
#

studio** You are now Level 3! **studio

pulsar drum
#

oh

#

you know what module scripts do

#

theyre things that let you share code

#

Across multiple scripts

shy plume
#

Ok so but I don't see a module script

#

Do you want me to like

#

Go inside a folder

#

And make a module script?

pulsar drum
#

yeah

shy plume
#

Like add a module script to something?

pulsar drum
#

wait

#

i think i should just make a code sample

#

gimme a sec

shy plume
#

You're the goat bro

pulsar drum
#

send me ur script actually

#

I wanna see

shy plume
#

Ok what script

pulsar drum
#

Anything related

#

that captures ur problem

shy plume
#

I mean I havent done anything

#

The only thing I did was

pulsar drum
#

oh

shy plume
#

Make the button

#

I already have the run and walk for the r key

#

I just need to make it for the button

#

But I don't know how to

#

Want me to show you?

#

@pulsar drum

#

Do you see

pulsar drum
#

local UserInputService = game:GetService("UserInputService")

local function playAnimation()
print("animation played")
-- blah blah
end

UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.R then
playAnimation()
end
end)

local button = game.StarterGui.TextButton

button.MouseButton1Click:Connect(function()
playAnimation()
end)

#

does this answer the question

shy plume
#

You want me to do this

#

So i copy this

#

And paste it

#

?

pulsar drum
#

it checks if u inputed “r” or press a pre made button and fires the same code

shy plume
#

Ok

shy plume
#

@pulsar drum

#

Yo you there

#

Yo kool

#

@pulsar drum

#

What if

#

Yo Kool it's fine I don't think you can help me

glad flareBOT
#

studio** You are now Level 4! **studio

shy plume
#

YO KOOL

#

LETS GO

#

@pulsar drum

#

@pulsar drum

#

@pulsar drum

#

Kool

#

Kool

#

I did It

#

@pulsar drum

#

Kool can you respond please

#

I don't need help anymore

#

I finished it

#

It works

#

Kool