I’m trying to make a part move from different position every time remote event is fired.
The problem is I don’t know how to move it.
local Part = game.Workspace:FindFirstChild("Part")
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local YValue = (-10)
RE.OnServerEvent:Connect(function()
Part.Position = Vector.new(0, YValue, 0)
end)
local Part = game.Workspace:FindFirstChild("Part")
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local YValue = (-10)
RE.OnServerEvent:Connect(function()
Part.Position = Vector3.new(0, (Part.Position + YValue), 0)
end)
local Part = game.Workspace:FindFirstChild("Part")
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local YValue = -10
RE.OnServerEvent:Connect(function()
Part.Position = Vector3.new(0, Part.Position.Y + YValue, 0)
end)
The main reason your code didn’t work was because you forgot to put “3” at the end of “Vector”
The other scripts could be improved. Here is the way I would do it:
local Part = game.Workspace:FindFirstChild("Part")
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local YValue = -10
RE.OnServerEvent:Connect(function()
Part.Position += Vector3.new(0, YValue, 0)
end)
The reason I didn’t do “-=” is because there’s no need to, it’ll just make it harder to understand and your script won’t work since you forgot to change “Vector” to " Vector3".
Indicates that they want it to be able to occur multiple times. This would lend itself to allowing the value to go down incrementally, which is why I feel -= or += should be used
Thank for all the replies!
A bit of edit, and…my work is done.
local Part = game.Workspace:FindFirstChild("Part")
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local YValue = (10)
RE.OnServerEvent:Connect(function()
Part.Position = Vector3.new(Part.Position.X, (Part.Position.Y - YValue), Part.Position.Z)
print("Succes")
print(Part.Position)
end)