Why Isn't the Doesn't the Gui Position Replicated to Client When Changed on the Client?

im making a minigame for my game where basically you click and it moves a frame and every tenth of a second it moves the frame back and if the frame makes it past halfway to another frame called reach it breaks but for some reason if i print it out its the right position but if i go onto explore its still the position i had set it two before i tested.

Script –

function Handler.Pull(Pull)
	local ReachPositon = 0.5
	local Finshed = false
	local OrgPostion = Pull.Position
	UserInputSerivce.InputBegan:Connect(function(Inp,proc)
		if proc then return end
		if Inp.UserInputType == Enum.UserInputType.MouseButton1 or  Inp.UserInputType == Enum.UserInputType.Touch then
			Pull.Position = Pull.Position + UDim2.fromScale(.021,0)
		end
	end)
	while task.wait(.1) do
		if Pull.Position == UDim2.new(.5,0,Pull.Position.X) then
			Finshed = true
			print("hi")
			break
		end
		Pull.Position = Pull.Position - UDim2.fromScale(.01,0)
		print(Pull.Position)
	
	end
	if Finshed == true then
		print("Reached Pass Thing!")
	end
end
1 Like

This can be due to sending the Pull variable from startergui like StarterGui.PullGui, instead send it through the player itself. There is also a typo on UserInputService but that probably doesnt affect your script if it is defined that way

no it didn’t work i changed all of the pull position to a the playerspull but it didn’t work sadly. it does print its new position its really weird i would’ve thought that would work. I did however fins the problem it is the if statement because my dumb brain checked the starter Gui position on client rather than the player Gui so it does change.

updated script -

function Handler.Pull(Pull)
	local ReachPositon = 0.5
	local Finshed = false
	local OrgPostion = Pull.Position
	local PlayerPull = game:GetService("Players").LocalPlayer.PlayerGui.PuzzleGui.PullFrame.Pull
	UserInputSerivce.InputBegan:Connect(function(Inp,proc)
		if proc then return end
		if Inp.UserInputType == Enum.UserInputType.MouseButton1 or  Inp.UserInputType == Enum.UserInputType.Touch then
			PlayerPull.Position = PlayerPull.Position + UDim2.fromScale(.021,0)
			--PlayerPull.Position = Pull.Position
		end
	end)
	while task.wait(.1) do
		if PlayerPull.Position == UDim2.new(.5,0,Pull.Position.X,0) then
			print("yes it is")
			Finshed = true
			print("hi")
			break
		end
		PlayerPull.Position = PlayerPull.Position - UDim2.fromScale(.01,0)
	--	PlayerPull.Position = Pull.Position
		
	
	end
	if Finshed == true then
		print("Reached Pass Thing!")
	end
end
1 Like

Thats basically what I suggested? I am glad you found the solution.

2 Likes

no i was getting the right pull variable because i was using a local script (pull is a script.Parent) then calling a function to a module with the pull in the agreements and it still doesn’t work.

1 Like

so i ask ai if you could it said yes but i got a error and after playing around with its prompt this worked

local uiElement = script.Parent
local thresholdPosition = UDim2.new(1, 0, 1, 0) -- Example threshold position

if uiElement.Position.X.Scale < thresholdPosition.X.Scale then
	print("UI element is past the threshold position")
else
	print("UI element is not past the threshold position")
end

final script -

function Handler.Pull(Pull)
	local ReachPositon = UDim2.new(0.5,0,Pull.Position.Y,0)
	local Finshed = false
	local OrgPostion = Pull.Position
	local PlayerPull = game:GetService("Players").LocalPlayer.PlayerGui.PuzzleGui.PullFrame.Pull
	UserInputSerivce.InputBegan:Connect(function(Inp,proc)
		if proc then return end
		if Inp.UserInputType == Enum.UserInputType.MouseButton1 or  Inp.UserInputType == Enum.UserInputType.Touch then
			PlayerPull.Position = PlayerPull.Position + UDim2.fromScale(.021,0)
		
		end
	end)
	while task.wait(.1) do
		if PlayerPull.Position.X.Scale > ReachPositon.X.Scale  then
			Finshed = true
		
			break
		end
		PlayerPull.Position = PlayerPull.Position - UDim2.fromScale(.01,0)	
	end
	if Finshed == true then
		print("Reached Pass Thing!")
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.