Hello and I am FestiveHarith, I am trying to achieve controlling and changing the values of roblox customphysicalproperties
(Here is the link from the roblox dev reference
BasePart.CustomPhysicalProperties)
I have tried to get it to work but the values will not change, I tried using variables and then try using int values (Its good to note that I am using roblox base water and NOT a custom part as water)
I have been searching the web but my idea hasn’t really been tried before, and my goal is actually to make custom buoyancy, so I have tried every trick in the book.
I have gone for 2 different ways of doing this.
- First using variables instead of Values.
local friction = 1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1
local density = script.DV1
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local hrp = char:FindFirstChild("HumanoidRootPart")
local Userinputservice = game:GetService("UserInputService")
Userinputservice.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode("Q") then
local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
hrp.CustomPhysicalProperties = physProperties
end
end)
2. With Values I have two different scripts, one in ServerScriptStorge (Seen below) and another that i have disabled
local densityVal = game.ReplicatedStorage.DV1
game.StarterGui.ScreenGui.Frame.Positive.MouseButton1Click:Connect(function()
densityVal.Value = densityVal.Value + 0.1
end)
game.StarterGui.ScreenGui.Frame.Negitive.MouseButton1Click:Connect(function()
densityVal.Value = densityVal.Value - 0.1
end)
local friction = 1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1
local densityVal = game.ReplicatedStorage.DV1
db = true
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local hrp = char:FindFirstChild("HumanoidRootPart")
local Userinputservice = game:GetService("UserInputService")
local physProperties = PhysicalProperties.new(densityVal, friction, elasticity, frictionWeight, elasticityWeight)
hrp.CustomPhysicalProperties = physProperties
game.StarterGui.ScreenGui.Frame.Positive.MouseButton1Click:Connect(function()
densityVal.Value = densityVal.Value + 0.1
local physProperties = PhysicalProperties.new(densityVal, friction, elasticity, frictionWeight, elasticityWeight)
hrp.CustomPhysicalProperties = physProperties
wait(0.1)
end)
game.StarterGui.ScreenGui.Frame.Negitive.MouseButton1Click:Connect(function()
densityVal.Value = densityVal.Value - 0.1
local physProperties = PhysicalProperties.new(densityVal.Value, friction, elasticity, frictionWeight, elasticityWeight)
hrp.CustomPhysicalProperties = physProperties
wait(0.1)
end)
I hope you can help me!
Thanks Harith!