Gui player move

I got rid of all the errors but that doesn’t necessarily make the code work. Maybe it was a mistake on your end.

Here full script:

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local aw = game.StarterGui.ScreenGui.aw
local ScreenGui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local posX = 0
local posY = 0
local velocityX = 0
local velocityY = 0

local mover = script.Parent
local speed = 100 


RunService.RenderStepped:Connect(function(dt)

	posX = posX + velocityX * dt * speed
	posY = posY + velocityY * dt * speed
	mover.Position = UDim2.new(
		0, posX,
		0, posY
	)
end)
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, processed)
	if processed then return end
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local key = input.KeyCode
		if key == Enum.KeyCode.W then
			game.StarterGui.ScreenGui:WaitForChild("aw") if UIS:IsKeyDown(Enum.KeyCode.W) then game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508139738" else game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508563011" end
		elseif key == Enum.KeyCode.A then game.StarterGui.ScreenGui:WaitForChild("aw") if UIS:IsKeyDown(Enum.KeyCode.A) then game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508563011" else game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508139738" end
		elseif key == Enum.KeyCode.S then game.StarterGui.ScreenGui:WaitForChild("aw") if UIS:IsKeyDown(Enum.KeyCode.S) then game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508139738" else game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508563011" end
		elseif key == Enum.KeyCode.D then game.StarterGui.ScreenGui:WaitForChild("aw") if UIS:IsKeyDown(Enum.KeyCode.D) then  game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508563011" else game.StarterGui.ScreenGui.aw.Image = "rbxassetid://9508139738" end	
		end
	end
end)

UserInputService.InputBegan:Connect(function(input, processed)
	if processed then return end
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local key = input.KeyCode
		
		if     key == Enum.KeyCode.W then velocityY = (if UserInputService:IsKeyDown(Enum.KeyCode.S) then 0 else -1)
		elseif key == Enum.KeyCode.A then velocityX = (if UserInputService:IsKeyDown(Enum.KeyCode.D) then 0 else -1)
		elseif key == Enum.KeyCode.S then velocityY = (if UserInputService:IsKeyDown(Enum.KeyCode.W) then 0 else  1)
		elseif key == Enum.KeyCode.D then velocityX = (if UserInputService:IsKeyDown(Enum.KeyCode.A) then 0 else  1)
		end
	end
end)

UserInputService.InputEnded:Connect(function(input, processed)
	if processed then return end
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local key = input.KeyCode

		if     key == Enum.KeyCode.W then velocityY = (if UserInputService:IsKeyDown(Enum.KeyCode.S) then  1 else 0)
		elseif key == Enum.KeyCode.A then velocityX = (if UserInputService:IsKeyDown(Enum.KeyCode.D) then  1 else 0)
		elseif key == Enum.KeyCode.S then velocityY = (if UserInputService:IsKeyDown(Enum.KeyCode.W) then -1 else 0)
		elseif key == Enum.KeyCode.D then velocityX = (if UserInputService:IsKeyDown(Enum.KeyCode.A) then -1 else 0)
		end
	end
end)

also
thing.rbxm (4.4 КБ)

Your script don’t give me any errors, but doesn’t change texture :slightly_frowning_face:

I think that the wrong line might be here.

if input.UserInputType == Enum.UserInputType.Keyboard then

Instead of using that I use

if input.KeyCode == Enum.KeyCode.W then -- your key here

It should look like this?

Screenshot 2022-04-30 at 22.04.01

Or this

Screenshot 2022-04-30 at 22.05.06

Oh, I messed up. I meant to say:

if Input.KeyCode == Enum.KeyCode.W then

It’s emphasized :slightly_frowning_face: (11112312312)

Did you put an end for that line?

this?

It’s because the i is capitalized.

not it’s not emphasized, so i should make this for every key? a,d,s

Try it. If it doesn’t work then tell me.

Okay, i will try this :grinning: (121231231231)
Now end is emphasized, i removed it (where player texture changes)
and now
end
end
end)
on end of a script is emphasized, what should i do?

It’s because i removed end in script that changes player texture, and when i get it back, it’s emphasized there

Screenshot 2022-04-30 at 22.18.59


Try adding or removing an end. If that doesn’t work, remove the bracket on one of the ends.

Tried, nothing worked, i removed bracket at top, and down, still emphized

Try adding or removing 2 ends.

Didn’t help too :slightly_frowning_face: (1231231231)

What exactly is the error in the script?

It either emphized in top script when i leave ends in end of a script, or down, when i remove ends in top of a script


when i leave ends in end of a script

this is end of a script when i remove ends in top

So i just made this texture change script as separate script