Can somoene tell me why my script doesnt work? I cant understand.
So what am I trying to do? I want that my coin goes up and down with a rotation itself.
what have I been scripting so far?
local Part = game.Workspace.Part
local Runservice = game:GetService("RunService")
local t = 0
Runservice.RenderStepped.Connect(function(dt)
t += dt
local PartY = Part.Position.Y + math.sin(t*math.rad(90))
Part.CFrame = CFrame.new(Part.Position.X,PartY,Part.Position.Z)
end)
You should define a “base” position, otherwise you are just incrementing the height.
local Part = game.Workspace.Part
local Runservice = game:GetService("RunService")
local t = 0
local y0 = Part.Position.Y
Runservice.RenderStepped.Connect(function(dt)
t += dt
local PartY = y0 + math.sin(t*math.rad(90))
Part.CFrame = CFrame.new(Part.Position.X,PartY,Part.Position.Z)
end)
Also, if this is a server script then you should use either the Stepped event or the Heartbeat event. RenderStepped only works in local scripts.