ok, i’ve been working on a mobile run button for my game and it just seems to need it’s own serverscript to function, although i was hoping that there was a way that i could use this mobile run button to just make it fire as an left-shift input to the client/server, instead of having to create a new run script.
is there any way i could do this? here is my run button script as of now:
-- I followed a tutorial as I had no idea how to go about doing this.
local cas = game:GetService("ContextActionService")
local run = Enum.KeyCode.LeftShift
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("runre")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local rootpart = char:WaitForChild("HumanoidRootPart")
local function handleContext(name, state, input)
if state == Enum.UserInputState.Begin then
re:FireServer(24)
else
re:FireServer(16)
end
end
cas:BindAction("Sprint", handleContext, true, run)
cas:SetPosition("Sprint", UDim2.new(.2,0,.5,0))
cas:SetTitle("Sprint", "Sprint")
cas:GetButton("Sprint").Size = UDim2.new(.3,0,.4,0)
i put this localscript in starterplayerscripts, if that helps.
thank you for reading!