#Playerball script not working
1 messages · Page 1 of 1 (latest)
local event = game.ReplicatedStorage.MakePlayerBallSignal
local part = game.Workspace.ConvertToBallPart
local Runservice = game:GetService("RunService")
event.OnServerEvent:Connect(function(PlayerModel)
part.Touched:Connect(function(otherpart)
local char = otherpart.Parent
local HRP = char:WaitForChild("HumanoidRootPart")
local marble = game.ServerStorage:WaitForChild("Marble"):Clone()
marble.Parent = char
marble.Position = HRP.Position
local Velocity = Instance.new("BodyAngularVelocity")
Velocity.Parent = marble
local Hum = char:WaitForChild("Humanoid")
local Weld = Instance.new("Weld")
Weld.Parent = marble
Weld.Part0 = HRP
Weld.Part1 = marble
Hum.PlatformStand = true
Runservice:BindToRenderStep("BallCalc", 2, function()
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
if game.Players.LocalPlayer.Character:FindFirstChild("Marble") then
game.Players.LocalPlayer.Character:FindFirstChild("Marble"):Destroy()
end
end)
end)
end)
end)
local event = game.ReplicatedStorage.MakePlayerBallSignal
event.OnClientEvent:Connect(function(PlayerModel)
game:GetService("RunService").RenderStepped:Connect(function()
if game.Players.LocalPlayer.Character:FindFirstChild("Marble") then
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = game.Players.LocalPlayer.Character.Marble
else
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = game.Players.LocalPlayer.Character.Head
end
end)
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
if game.Players.LocalPlayer.Character:FindFirstChild("Marble") then
game.Players.LocalPlayer.Character:FindFirstChild("Marble"):Destroy()
end
end)
end)
The first script is from the server side, and the 2nd one is the client side
This screams memory leak… Why are you also deleting the marble both on client and server side?
Can you elaborate on your issue a bit more? Exactly what isn’t working? Are there any errors?