Part not moving/Script not working

I have a script of mine that I tried to change to make it simpler, but it stopped working after a few changes.

--client (StarterPlayerScripts)--

local REP = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")

local remote = REP.Lift

UIS.InputBegan:Connect(function(input, gp)
	if gp then return end
	if input.KeyCode == Enum.KeyCode.E then
		remote:FireServer(true)
	end
end)

UIS.InputEnded:Connect(function(input, gp)
	if gp then return end
	if input.KeyCode == Enum.KeyCode.E then
		remote:FireServer(false)
	end
end)
--server (ServerScriptService)--

local REP = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")

local remote = REP.Lift

local Vehicle = game.Workspace.Mover.Vehicle
local Move

RS.Heartbeat:Connect(function()
	if Move then
		Vector3.new(0,0.5,0)
	end
end)

remote.OnServerEvent:Connect(function(plr, state)
	Move = state
end)

I just want the part to simply move up and down, but I’m not sure how to revert it to that.
(also how to make sure it only works when fired by me and not anyone else)

3 Likes

p.s. The part I want to move is a model

1 Like

Try using tween service

2 Likes

quick question, but why are you creating a vector3 on the heartbeat? If I remember correctly, that won’t do anything if you dont actually use the value? (or am I remembering wrong?)

2 Likes

I doubt I even need to use heartbeat here, I just don’t remember what I was using before, so now I can’t fix it, plus implementing a tween, as the user above just suggested.

2 Likes

I see
First off, using a tween is probably better, but even more importantly, you notice that your script doesn’t actually move any parts? I would assume the “Vector3.new(0, 0.5, 0)” is meant to move the part, in which case it currently is not doing so, as its only creating the vector3 and not applying to to anything. You could try adding or setting the part’s cframe value by that (something like that, I can’t remember exactly how you do it)

2 Likes

What exactly is gp?
Your functions both end if gp is true.

You can also troubleshoot your if statements with prints to let you know if they are connecting. If the print lines don’t show up then you can find out where the issue is in your script:

UIS.InputBegan:Connect(function(input, gp)
	if gp then return end
	if input.KeyCode == Enum.KeyCode.E then
        print("E pressed")
		remote:FireServer(true)
	end
end)

UIS.InputEnded:Connect(function(input, gp)
	if gp then return end
	if input.KeyCode == Enum.KeyCode.E then
        print("E released")
		remote:FireServer(false)
	end
end)
2 Likes

It does say it was pressed, it’s just the server script that doesn’t work.

1 Like

OP has reposted this same issue here…

1 Like