Ok, so I have a sword shop that when I press the button the sword from the ReplicatedStorage goes to the Backpack. That works fine. The problem is that it doesn't seem to deal damage when I activate it even though it had worked fine when I tested it by putting it in the Starterpack. Please help.
Sword client (a local script inside the tool/sword):
wait(0.6) script.Parent.Equipped:Connect(function() local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animations.Idle) wait(0.1) idle:Play() script.Parent.Unequipped:Connect(function() idle:Stop() end) end) --//Attacking Animations\\-- local UserInputService = game:GetService("UserInputService") local Tool = script.Parent local CanAttack = true local Anim_Name = "Attack" local Audio = script.Parent:WaitForChild("Handle"):WaitForChild("Swing") local Attack_Animations = script.Parent:WaitForChild("Animations") local Attack_Num = 1 local blade = script.Parent:WaitForChild("ScytheBlade") local RE = Tool.RemoteEvent local OneHitEvent = Tool.OneHitEvent local OneHit = Tool.OneHit blade.Touched:Connect(function(hit) if CanAttack == false and OneHit.Value and script.Parent.Parent == game.Players.LocalPlayer then OneHitEvent:FireServer() RE:FireServer() end end) Tool.Activated:Connect(function() OneHit.Value = true local Animation = script.Parent.Parent.Humanoid:LoadAnimation(Attack_Animations[Anim_Name..Attack_Num]) if CanAttack == true then CanAttack = false Animation:Play() Audio:Play() wait(0.7) CanAttack = true if Attack_Num == 1 then Attack_Num = Attack_Num + 1 else if Attack_Num == 2 then Attack_Num = 1 end end end end) Tool.Deactivated:Connect(function() script.Parent.Equipped:Connect(function() local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animations.Idle) wait(0.1) idle:Play() script.Parent.Unequipped:Connect(function() idle:Stop() end) end) end)
Server script (a normal script inside the tool):
local RemoteEvent = script.Parent.RemoteEvent local Damage = 10 local blade = script.Parent.Blade local OneHit = script.Parent.OneHit local RE = script.Parent.OneHitEvent local TD = true RE.OnServerEvent:Connect(function(plr) OneHit.Value = true end) RemoteEvent.OnServerEvent:Connect(function(plr) blade.Touched:Connect(function(h) if h:IsA("BasePart") and h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and TD and OneHit.Value then TD = false local Humanoid = h.Parent.Humanoid Humanoid:TakeDamage(Damage) local indicator = game:GetService("ReplicatedStorage"):FindFirstChild("DmgIndicator") -- we put the dmgindicator which in in the replicatedstorage inside a variable if indicator then -- we check whether the indicator exists, if so then... local gui = indicator:Clone() -- we clone it and store the cloned version inside a variable gui.Parent = h.Parent:FindFirstChild("HumanoidRootPart") -- we put the cloned version inside the enemy's rootpart gui.Damage.Text = "-"..tostring(Damage) -- we set the damage text to the damage we'll deal gui.StudsOffset = Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2)) -- we position our gui randomly on the enemy's body (between -2 and 2 studs) wait(0.75) game.Debris:AddItem(gui,0.1) OneHit.Value = false TD = true end end end) end)
There are 2 remote events: one named OneHitEvent one named RemoteEvent
Also, there is a bool value named OneHit
In the output, it states no errors but there clearly is.
Any scripts that come from ReplicatedStorage will not transfer well to Workspace.
Try cloning it from Workspace or lighting.
Edit: Have to tool in StarterPack and disable it. Enable when the player should use/have it.
Happy scripting, Tim