Im trying to make a script where when you click on a part, it gives you a tool (already done that), but problem is, the tool simply wont activate. No errors even appear. What?
local DefaultBall = game.Workspace.DefaultBall
DefaultBall.glass.Case.ClickDetector.MouseClick:Connect(function(Player)
local Character = Player.Character
local Humanoid = Character.Humanoid
-- Ball
local Ball = script.Parent.Default_Ball
local Tool = script.Parent
local character = Tool.Parent
-- Animation
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://13962251515"
-- Settings
local debounce = false -- Cooldown
Animation.Parent = Humanoid.Animator
Tool.Activated:Connect(function(activated)
local HitAnimPlay = Humanoid:LoadAnimation(Animation)
if not debounce then
debounce = true
HitAnimPlay:Play()
wait(1.5)
debounce = false
end
end)
Ball.Touched:Connect(function(hit)
local enemyplayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if not debounce then
if enemyplayer then
enemyplayer.Character.Humanoid.Health = - 10
debounce = true
wait(1.5)
debounce = false
end
end
end)
end)
as @Deb0rahAliWilliams suggested, can you place some print statements around? Which ones print and which ones don’t? Specifically, in the Tool.Activated location and inside the conditional.
If the Script you placed in at the first post is the one under the tool, why not just disable the Script under the tool, and when the Player clicks on the Case, the Script would just modify the Script to make in enabled?
This would be something that should be on the giver.
-- Variables
local Tool = game.ServerStorage:WaitForChild("Deafult_Ball")
-- Connecting when the ClickDetector gets triggered
script.Parent.MouseClick:Connect(function(plr)
-- Cloning the tool itself
local ToolClone = Tool:Clone()
ToolClone.Parent = plr.Backpack
ToolClone.Script.Enabled = true
end
end)
If this script is added, this means you don’t need to add this line to the Script, which may help debug your animation not playing:
I will be going offline for the night, so I won’t be responding to any replies that are within ~9 hours from when this reply is written.