-
What do you want to achieve? Not make the variable change without me wanting it to.
-
What is the issue? The variable randomly changes for no reason.
-
What solutions have you tried so far? Cannot find anything anywhere. I’ve surfed the web.
local Object = self.Object
local DragInput = nil
local DragStart = nil
local StartPosition = nil
local PreparingToDrag = false
local function Update(Input)
local Delta = Input.Position - DragStart
TweenService:Create(self.Object, TweenInfo.new(DragSpeed), {Position = UDim2.new(StartPosition.X.Scale, StartPosition.X.Offset + Delta.X, StartPosition.Y.Scale, StartPosition.Y.Offset + Delta.Y)}):Play()
end
self.InputBegan = Object.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
if not CurrentlyDragging then
print("Began")
CurrentlyDragging = true
DragStart = Input.Position
StartPosition = Object.Position
print(DragStart) -- prints a Vector3
print(StartPosition) -- prints a UDim2
end
end
end)
self.InputChanged = UserInputService.InputChanged:Connect(function(Input, GPE)
if GPE then
return
end
if Input.UserInputType == Enum.UserInputType.MouseMovement or Input.UserInputType == Enum.UserInputType.Touch then
if CurrentlyDragging then
print(DragStart) -- prints nil
print(StartPosition) -- prints nil
Update(Input)
end
end
end)
self.InputEnded = Object.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
print("Ended")
print(DragStart) -- prints a Vector3
print(StartPosition) -- prints a UDim2
CurrentlyDragging = false
print(DragStart) -- prints nil
print(StartPosition) -- prints nil
end
end)
Any reason for this? This isn’t the full code, but it is the relevant areas, and the only area where the variables change.