I wanted to make a function that changes gravity after 5 seconds and changes again after 10 seconds.
I used delay and wrote a module script function in the brackets. But for some reason it only works if i press space.
local script :
local module = require(script:WaitForChild(“ModuleScript”))
local hit = true
if hit == true then
print(“ye”)
delay(5,module.print)
delay(7,module.prinet)
end
Modulescript:
local module = {}
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local bodyForce = Instance.new(“BodyForce”,char.PrimaryPart)
bodyForce.Force = Vector3.new(0, 0, 0)
module.print = function()
print(“yes”)
bodyForce.Force = (Vector3.new(6000,0,6000)*cam.CFrame.LookVector)+Vector3.new(0,10000,0)
end
module.prinet = function()
print (“ok”)
bodyForce.Force = Vector3.new(0,0,0)
end
return module
– [[so if i start the game it prints yes after 5 sekonds and ok after 7 . But the change of the gravity only works if i hit space. ]]–
ps: an even if i hit space the gravity doest work as it should. The gravitation should carry me in the direction where i’m looking but it does not.