I don’t know what to do.
Certified Ragdoll Moment
Could we see the script that’s supposed to pick up the potion? You may have the server/client changes mixed up or something perhaps
I’m still trying to figure out what’s happening in the video
The only actual thing that I really see is that you’re setting the NetworkOwner’s Part to the _G.player
which could be why? But I’m not sure
And that isn’t the problem i tested. (the setnetworkownership)
Would it be something to do with the names?
Why are you using _G
in this case if I may ask?
that’s why i could do it a different way but can’t be stuffed.
OnServerEvent
returns the player who fired the event, you don’t really need to use _G
, not even for the tweening event as you can just disconnect it via a condition. It’s probably conflictions related to that. Could you send the code as code as code blocks for the touched event and onServeEvent instead of images so I can easily edit it to show you what I mean
local runservice = game:GetService("RunService")
local tweenservice = game:GetService("TweenService")
local replicatedstorage = game:GetService("ReplicatedStorage")
local part = script.Parent
local debounce = false
local touched = false
local throwpot = replicatedstorage:WaitForChild("throwpot")
part.Touched:Connect(function(hit)
if touched == false then
if hit.Parent:FindFirstChild("Humanoid") then
_G.player = game.Players:GetPlayerFromCharacter(hit.Parent)
if _G.player.Character.HasPotion.Value == false then
_G.player.Character.HasPotion.Value = true
touched = true
part:SetNetworkOwner(_G.player)
part.Anchored = true
part.CanCollide = false
_G.tween = runservice.Heartbeat:Connect(function()
--part.CFrame = hit.Parent:FindFirstChild("Right Arm").CFrame
local Time = 0.005
local tween = tweenservice:Create(part, TweenInfo.new(Time),{CFrame = _G.player.Character.Torso.CFrame - _G.player.Character.Torso.CFrame.LookVector*2})
tween:Play()
--part.AssemblyAngularVelocity = Vector3.new(0,0,0)
end)
end
end
end
end)
replicatedstorage.drop.OnServerEvent:Connect(function()
if touched == true then
if _G.player.Character.HasPotion.Value == true then
part.Anchored = false
part.CanCollide = true
_G.player.Character.HasPotion.Value = false
_G.tween:Disconnect()
touched = false
end
end
end)
throwpot.OnServerEvent:Connect(function(playr, mousehit)
if touched == true then
if _G.player.Character.HasPotion.Value == true then
part.Anchored = false
part.CanCollide = true
_G.player.Character.HasPotion.Value = false
_G.tween:Disconnect()
part:SetNetworkOwner(playr)
part.CFrame = _G.player.Character.Torso.CFrame - _G.player.Character.Torso.CFrame.LookVector *-3
part.Touched:Connect(function(hit)
if hit:IsA("Part") then
if not hit:IsDescendantOf(playr.Character) then
print(hit)
part.Anchored = true
local Time = 0.15
local tween = tweenservice:Create(part, TweenInfo.new(Time),{Transparency = 1})
tween:Play()
local fire = game:GetService("ReplicatedStorage").Push:Clone()
fire.Parent = workspace
fire.Position = part.Position
local time_ = 1
local tween1 = tweenservice:Create(fire, TweenInfo.new(time_),{Size = Vector3.new(9,0.025,9)})
tween1:Play()
tween.Completed:Wait()
game:GetService("ServerScriptService").ItemSpawn.Spawned.Value = game:GetService("ServerScriptService").ItemSpawn.Spawned.Value-1
part:Destroy()
tween1.Completed:Wait()
wait(1)
fire:Destroy()
end
end
end)
local bv = Instance.new("BodyVelocity", part)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = playr.Character.Torso.CFrame.lookVector*45 + Vector3.new(0,10,0)
local bv1 = Instance.new("BodyVelocity", playr.Character["Right Arm"])
bv1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv1.Velocity = playr.Character.Torso.CFrame.lookVector*3 + Vector3.new(0,7,0)
local bv2 = Instance.new("BodyVelocity", playr.Character["Torso"])
bv2.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv2.Velocity = Vector3.new(0,-1,0)
wait(0.2)
bv1:Destroy()
bv2:Destroy()
bv:Destroy()
end
end
end)
Try this out
local runservice = game:GetService("RunService")
local tweenservice = game:GetService("TweenService")
local replicatedstorage = game:GetService("ReplicatedStorage")
local part = script.Parent
local debounce = false
local touched = false
local throwpot = replicatedstorage:WaitForChild("throwpot")
part.Touched:Connect(function(hit)
if touched == false then
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.Character.HasPotion.Value == false then
player.Character.HasPotion.Value = true
touched = true
part:SetNetworkOwner(player)
part.Anchored = true
part.CanCollide = false
local tweenevent
tweenevent = runservice.Heartbeat:Connect(function()
--part.CFrame = hit.Parent:FindFirstChild("Right Arm").CFrame
if not player.Character.HasPotion.Value then tweenevent:Disconnect() end
local Time = 0.005
local tween = tweenservice:Create(part, TweenInfo.new(Time),{CFrame = player.Character.Torso.CFrame - player.Character.Torso.CFrame.LookVector*2})
tween:Play()
--part.AssemblyAngularVelocity = Vector3.new(0,0,0)
end)
end
end
end
end)
replicatedstorage.drop.OnServerEvent:Connect(function(player)
if touched == true then
if player.Character.HasPotion.Value == true then
part.Anchored = false
part.CanCollide = true
player.Character.HasPotion.Value = false
touched = false
end
end
end)
throwpot.OnServerEvent:Connect(function(player, mousehit)
if touched == true then
if player.Character.HasPotion.Value == true then
part.Anchored = false
part.CanCollide = true
player.Character.HasPotion.Value = false
part:SetNetworkOwner(player)
part.CFrame = player.Character.Torso.CFrame - player.Character.Torso.CFrame.LookVector *-3
part.Touched:Connect(function(hit)
if hit:IsA("Part") then
if not hit:IsDescendantOf(player.Character) then
print(hit)
part.Anchored = true
local Time = 0.15
local tween = tweenservice:Create(part, TweenInfo.new(Time),{Transparency = 1})
tween:Play()
local fire = game:GetService("ReplicatedStorage").Push:Clone()
fire.Parent = workspace
fire.Position = part.Position
local time_ = 1
local tween1 = tweenservice:Create(fire, TweenInfo.new(time_),{Size = Vector3.new(9,0.025,9)})
tween1:Play()
tween.Completed:Wait()
game:GetService("ServerScriptService").ItemSpawn.Spawned.Value = game:GetService("ServerScriptService").ItemSpawn.Spawned.Value-1
part:Destroy()
tween1.Completed:Wait()
wait(1)
fire:Destroy()
end
end
end)
local bv = Instance.new("BodyVelocity", part)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = player.Character.Torso.CFrame.lookVector*45 + Vector3.new(0,10,0)
local bv1 = Instance.new("BodyVelocity", player.Character["Right Arm"])
bv1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv1.Velocity = player.Character.Torso.CFrame.lookVector*3 + Vector3.new(0,7,0)
local bv2 = Instance.new("BodyVelocity", player.Character["Torso"])
bv2.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv2.Velocity = Vector3.new(0,-1,0)
wait(0.2)
bv1:Destroy()
bv2:Destroy()
bv:Destroy()
end
end
end)
I made it so it instead disconnects the event if HasPotion
is false so the tween can be disconnected like that instead
I’ll try it, Will it fix my problem?
Bruh that worked.Thanks!, It was unplayable with this mistake.
Anytime! I would recommend marking my post as the solution then if it has helped you! If you have anymore issues don’t be afraid to make another post!
Uh oh… You fixed it but there’s another problem
throwpot’s local script
local player = game:GetService("Players").LocalPlayer
local rp = game:GetService("ReplicatedStorage")
local throwpot = rp:WaitForChild("throwpot")
local uis = game:GetService("UserInputService")
local debounce = false
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if player.Character.HasPotion.Value == true then
throwpot:FireServer()
end
end
end)
The problem
Basically we just switched potions. and I could throw his potion, and he could throw mine.
Edit: Video didn’t render correct.
I grabbed the fire potion, He grabbed a push potion, I pressed left click, it used HIS push potion i pressed it on his side and it threw my potion.
I think the issue could be that you’re doing an OnServerEvent
for each potion, you’d have to make one OnServerEvent for both drop
and throwpot
and figure out a way to Fire the event giving it your Mouse hit position AND the potion you own
replicatedstorage.drop.OnServerEvent:Connect(function(player)
throwpot.OnServerEvent:Connect(function(player, mousehit)
I’ve already done that in the code though?