So I am making a button which can move the part up and down here’s how the code looks
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("PartClicked")
local originalCFrame = script.Parent.PrimaryPart.CFrame
remoteEvent.OnServerEvent:Connect(function(player, y, name)
if script.Parent.Name == game.Workspace.PartMoving.Value then
if name == "Up" or name == "MassUp" then
local newCFrame = originalCFrame + Vector3.new(0, y, 0)
originalCFrame = newCFrame
script.Parent:SetPrimaryPartCFrame(newCFrame)
end
elseif name == "Down" or name == "MassDown" then
local newCFrame = originalCFrame + Vector3.new(0, -y, 0)
originalCFrame = newCFrame
script.Parent:SetPrimaryPartCFrame(newCFrame)
end
end)
Now it’s really wierd, the down moves it like 20 studs up and up moves it up one stud and sometimes it moves it back where it originally was. Here’s the code from a locla script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("PartClicked")
local y = 0
local name = script.Parent.Name
script.Parent.Activated:Connect(function()
y = y + 1
remoteEvent:FireServer(y, name)
end)
Any help is appreciated and I've verified that the names are correctly and the down button is exactly as the local scirpt except for it changine y to y - 1