I was in the process of making a Mobile Button for a light switch
No matter what I tried it kept appearing in the logs that it can only be called in a local script. I’ve tried re-writing the script and making another localscript
---[{Vars}]
local LocalPlayer = game:GetService("Players").LocalPlayer
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local ClickSoundEFFECT = script.Parent.F_FlashLight:WaitForChild("FlashLightClick")
local Head = game.Players.LocalPlayer.Character:WaitForChild("Head")
local FlashLight = Head:WaitForChild("SurfaceLight")
local FlashLightState = game.ReplicatedStorage.FlashLightState
local GS = game:GetService("GuiService")
---[{Functions}]
function FlashlightOn()
FlashLight.Enabled = true
end
function FlashlightOff()
FlashLight.Enabled = false
end
function FullScript()
if FlashLightState.Value == true then
FlashLightState.Value = false
ClickSoundEFFECT:Play()
FlashlightOn()
else
FlashLightState.Value = true
ClickSoundEFFECT:Play()
FlashlightOff()
end
end
---[{Finds Player's Platforms}]
function getPlatform()
if (GS:IsTenFootInterface()) then
return "Console"
elseif (UIS.TouchEnabled and not UIS.KeyboardEnabled) then
return "Mobile"
else
return "Desktop"
end
end
---[{Don't Mess With Anything Here}]
if getPlatform() == "Mobile" then
CAS:BindAction("TurnOnAndOffFlashLight", FullScript, true, "f" )
end