I was making a script that edits the default touchscreen GUI and it works fine:
LocalScript in game.StarterGui
local Properties = {
Image = "rbxasset://textures/ui/TouchControlsSheet.png";
MouseDown = {
Size = Vector2.new(174, 174);
Pos = Vector2.new(0, 222);
};
MouseUp = {
Size = Vector2.new(174, 174);
Pos = Vector2.new(176, 222);
};
}
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
script.Parent.ChildAdded:Connect(function(Object)
if Object.Name == "TouchGui" then
local TouchControlFrame = Object:WaitForChild("TouchControlFrame")
local JumpButton = Instance.new("ImageButton")
JumpButton.BackgroundTransparency = 1
JumpButton.Size = TouchControlFrame.JumpButton.Size
JumpButton.Position = TouchControlFrame.JumpButton.Position
JumpButton.Image = Properties.Image
JumpButton.ImageRectSize = Properties.MouseUp.Size
JumpButton.ImageRectOffset = Properties.MouseUp.Pos
JumpButton.AutoButtonColor = false
TouchControlFrame.JumpButton:Destroy()
JumpButton.MouseButton1Down:Connect(function()
JumpButton.ImageRectSize = Properties.MouseDown.Size
JumpButton.ImageRectOffset = Properties.MouseDown.Pos
end)
JumpButton.MouseButton1Up:Connect(function()
JumpButton.ImageRectSize = Properties.MouseUp.Size
JumpButton.ImageRectOffset = Properties.MouseUp.Pos
end)
JumpButton.MouseLeave:Connect(function()
JumpButton.ImageRectSize = Properties.MouseUp.Size
JumpButton.ImageRectOffset = Properties.MouseUp.Pos
end)
JumpButton.Parent = TouchControlFrame
end
end)
until I add this line after line 13?
local Humanoid = Char:WaitForChild("Humanoid")
I made sure it exists by printing it and it does exist so I have no clue, please help.