Hi,
I’m using the roblox weaponskit in a game i’m building, am stuck trying to tell the shouldercamera that the humanoid walkspeed has changed.
I have a power-up that alters health or speed of a humanoid, it looks like the weaponskit shouldercamera sets a humanoids walkspeed to handle sprinting\not-sprinting and i cannot override it.
I’ve had a look around this forum and the web, cannot find anything to help, and I do not understand how to control the shouldercamera and its settings yet.
There’s three values inside the shouldercamera that I want to change for a specific player:
self.zoomWalkSpeed = 8
self.normalWalkSpeed = 20
self.sprintingWalkSpeed = 24
(these are located in the ShoulderCamera script in the weaponskit)
How do I change these for a player from a script serverside?
Thanks in advance!
1 Like
I figured this out and would like to share how I did it.
You will need to manage three integers to handle the speeds for walking, zooming and running, and poke them into the shouldercameras renderstep function, bypassing the defaults.
In your PlayerAdded function add the following which will create the three values for each player as they join:
local aConfiguration = Instance.new("Folder", Player)
aConfiguration.Name = "Configuration"
-- Handle walk speeds
local playerWalkSpeed = 16
local playerSprintingWalkSpeed = 24
local playerZoomWalkSpeed = 8
local playerWalkSpeed = Instance.new("IntValue", aConfiguration)
playerWalkSpeed.Name = "PlayerWalkSpeed"
playerWalkSpeed.Value = 16
local playerSprintingWalkSpeed = Instance.new("IntValue", aConfiguration)
playerSprintingWalkSpeed.Name = "PlayerSprintingWalkSpeed"
playerSprintingWalkSpeed.Value = 24
local playerZoomWalkSpeed = Instance.new("IntValue", aConfiguration)
playerZoomWalkSpeed.Name = "PlayerZoomWalkSpeed"
playerZoomWalkSpeed.Value = 8
Now to tweak the WeaponsSystem.
- Head to your WeaponsSystem folder in Replicated Storage.
- Expand Libraries and open the ShoulderCamera script.
- Find the ShoulderCamera:onRenderStep function
- The entire section titled “– Handle walk speed changes” needs to be commented out
- Insert the code shown below and put it above what you just commented out
-- Handle walk speed changes
local playerWalkSpeed = 16 -- Weaponskit default
local playerSprintingWalkSpeed = 24 -- Weaponskit default
local playerZoomWalkSpeed = 1 -- Weaponskit default
local player = Players:GetPlayerFromCharacter(self.currentHumanoid.Parent)
if player then
local playerConfiguration = player:FindFirstChild("Configuration")
playerWalkSpeed = playerConfiguration:FindFirstChild("PlayerWalkSpeed").Value
playerSprintingWalkSpeed = playerConfiguration:FindFirstChild("PlayerSprintingWalkSpeed").Value
playerZoomWalkSpeed = playerConfiguration:FindFirstChild("PlayerZoomWalkSpeed").Value
end
if self.sprintEnabled or self.slowZoomWalkEnabled then
self.desiredWalkSpeed = playerWalkSpeed
if self.sprintEnabled and (self.sprintingInputActivated or self:sprintFromTouchInput() or self:sprintFromGamepadInput()) and not self.zoomState then
self.desiredWalkSpeed = playerSprintingWalkSpeed
end
if self.slowZoomWalkEnabled and self.zoomAlpha > 0.1 then
self.desiredWalkSpeed = playerZoomWalkSpeed
end
ShoulderCamera.SpringService:Target(self.currentHumanoid, 0.95, 4, { WalkSpeed = self.desiredWalkSpeed })
end
Now all you have to do is change the players configuration data for any of the 3 walkspeeds from any server side script, and the WeaponsSystem will handle the changes for you instantly.
This pretty much opens up reconfiguration of most of what the properties the shouldercamera controls. Take a look at the ShoulderCamera.new function in ShoulderCamera for an idea of what can be changed.
2 Likes