Sup. I was making a script related to a syringe that can be used to treat yourself or other people. I made a local script in the syringe and a script in ServerScriptService to link them using RemoteEvent because the tool is used both on the server and the client.
When I checked the syringe with two players, I noticed that for other players the syringe in the first player’s hand was shown as an item, but in fact, it was removed from the first player’s hand after use. For the player who used the syringe, it is gone. Perhaps someone can let me know what’s wrong?
Local Script in the tool
local tool = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local mouse = game.Players.LocalPlayer:GetMouse()
local applyEffectEvent = ReplicatedStorage:WaitForChild("ApplySyringeEffect")
local originalCrosshair = "rbxassetid://11336293662"
local defaultCrosshair = "rbxassetid://11336293662"
tool.Activated:Connect(function()
local character = tool.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
if humanoid and player then
local target = mouse.Target
if target and target.Parent and target.Parent:FindFirstChild("Humanoid") then
applyEffectEvent:FireServer(target.Parent)
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://3043029786"
sound.Parent = character.Head
sound:Play()
tool.Parent = nil
return
end
applyEffectEvent:FireServer(character)
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://3043029786"
sound.Parent = character.Head
sound:Play()
tool.Parent = nil
end
end)
mouse.Move:Connect(function()
local target = mouse.Target
if target and target.Parent and target.Parent:FindFirstChild("Humanoid") then
tool.Handle.Crosshair = originalCrosshair
else
tool.Handle.Crosshair = defaultCrosshair
end
end)
Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local applyEffectEvent = ReplicatedStorage:WaitForChild("ApplySyringeEffect")
applyEffectEvent.OnServerEvent:Connect(function(player, target)
local targetHumanoid = target:FindFirstChild("Humanoid")
if not targetHumanoid then return end
local targetPlayer = game.Players:GetPlayerFromCharacter(target)
if targetPlayer then
local originalSpeed = targetHumanoid.WalkSpeed
targetHumanoid.WalkSpeed = originalSpeed + 8
targetHumanoid:TakeDamage(5)
wait(90)
targetHumanoid.WalkSpeed = targetHumanoid.WalkSpeed - 8
end
end)
Player 2’s POV (Another player)
Player 1s POV (The one who used the syringe)