Nvm I’m really dumb ima just give up
To create a script that will
- Create a new VectorForce instance
- Parent it to the player
- Is relative to where the character rotates
you can follow this guide:
Assuming you want to handle these calculations on the server, you should start by creating a new server script and parent it to ServerScriptService.
- Connect the .PlayerAdded signal from the Players service
game:GetService("Players").PlayerAdded:Connect(function(player)
end)
- Connect the .CharacterAdded signal from the “player” instance
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
end)
end)
- Create new Attachment and VectorForce instances, and apply relative properties
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local attachment = Instance.new("Attachment")
attachment.Parent = character:WaitForChild("Humanoid").RootPart
local force = Instance.new("VectorForce")
force.Attachment0 = attachment
force.Force = Vector3.new(0, 0, -5000)
force.Enabled = false
force.Parent = character
end)
end)
Since VectorForce’s have to be applied under a BasePart or Attachment, an Attachment is preferred since it has no physical presence in the environment. You do not have to worry about moving the force of the VectorForce, since it already rotates based on the Attachment’s position, which is relative to the character itself.
I hope this helped, let me know if you have any questions!
What the finished result should look like (gyazo gif)
Omg I’ve been waiting weeks through multiple posts on thx. 1 questions if this were to be a movement (rolling) where would the script be located for the optimal effect the character will roll when you press c whilst running, currently I have the input system ready and it is starter character scripts should I move it somewhere else or keep as is?
Yes, you can make a rolling action by forking this code. If you do not mind the client possibly tripping anti-exploit measures on the server the best place to put the code would be StarterCharacterScripts. This is because the code would run as the character is added making it more “on-demand” rather than always running. For reference, in the server-side example, two connections are being made, whereas if you used the client StarterCharacterScripts method you mentioned, there should be zero to one connection, assuming you’re using ContextActionService.
I would give my code to u rn but I can’t find the code thing on mobile but I’m using uis and have a local player variable so would I have to use the whole player added function and I’m not sure (as a noob) what I would change if I were to fork it sorry for asking so many questions
On the client you would not need the PlayerAdded signal unless you are wanting to listen for more than the local player since the script would run once the client player joins. Holding onto the assumption that you are using ContextActionService, it may be best to parent the script to StarterCharacterScripts so the roll action is bound once the character spawns in.
Sorry I didn’t make it clear enough I am using uis user input service but it doesn’t really matter any more. thank you
Yeah so um hate to annoy you again but for some reason, it worked before I added the code that was supposed to make it move but not it doesn’t even print roll (which means it’s not working)
And the forces aren’t working either.
Idk if I used the right variables but need help again
Also I forgot to mention another question how would I make the attachment \ vector force face towards and make the plate go that way
Nvm I realized I’m dumb and didn’t even add the example code and I’m just gonna give up
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.