Hello Developers, So I made a script that’s only useful for ScreenGui’s and I want to change it so it works with a SurfaceGui. But I don’t know how to. It doesn’t show any error it just doesn’t work at all please help.
The Code:
local UIS = game:GetService('UserInputService')
local TS = game:GetService('TweenService')
local TSI = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local RF = script.Parent:WaitForChild("RightBG"):WaitForChild("RightFrame")
local Bind = game.StarterPlayer.StarterCharacterScripts.Binds
local Storage = game.StarterPlayer.StarterCharacterScripts.HumanVals.HumanWS
local BarValue = Instance.new('NumberValue')
BarValue.Changed:Connect(function()
local Rot = math.clamp(BarValue.Value -180, -180, 0)
RF.Rotation = Rot
end)
BarValue.Value = 180
local function BarIncrease()
BarValue.Value = BarValue.Value
local Tween1 = TS:Create(Storage, TSI, {Value = Storage.Value + 52})
local Tween2 = TS:Create(BarValue, TSI, {Value = 180})
Tween1:Play()
Tween2:Play()
end
local function BarDecrease()
BarValue.Value = BarValue.Value
local Tween1 = TS:Create(Storage, TSI, {Value = Storage.Value - 52})
local Tween2 = TS:Create(BarValue, TSI, {Value = 0})
Tween1:Play()
Tween2:Play()
end
UIS.InputBegan:Connect(function(Input, gameProccesedEvent)
if Input.KeyCode == Enum.KeyCode[Bind.StamBind.Value] then
BarDecrease()
end
end)
UIS.InputEnded:Connect(function(Input, gameProccesedEvent)
if Input.KeyCode == Enum.KeyCode[Bind.StamBind.Value] then
BarIncrease()
end
end)