Hello, I was putting a tool in the replicated storage, and giving it to players if they own a gamepass for the tool, but when I put the tool in the ReplicatedStorage, the tool does not play the “Slash” animation, and it does not do any damage. When I put the tool in the StarterPack, the tool works fine.
This is the script for the tool, this is a script inside the tool (I followed Tech with Mike’s YouTube tutorial on how to make a tool.):
local tool = script.Parent
local canDamage = false
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(25)
else
return
end
canDamage = false
end
local function slash()
local stringValue = Instance.new("StringValue")
stringValue.Name = "toolanim"
stringValue.Value = "Slash"
stringValue.Parent = tool
canDamage = true
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
Also this is the script for giving the tool when they have the gamepass (I followed @Eppobot’s tutorial on how to make a gamepass):
local player = game.Players.LocalPlayer
local playerOwnsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19237750)
if playerOwnsGamepass then
local frozenStick = game:GetService("ReplicatedStorage"):WaitForChild("FrozenStick"):Clone()
frozenStick.Parent = player.Backpack
end
Scripts don’t run inside of ReplicatedStorage, not sure if this is shared between ReplicatedStorage and Lighting but it’s just something you could try. See if it works!
To change your code to work with Lighting simply change ReplicatedStorage to Lighting.
Using the start local server feature? Did you manually give yourself the tools and try to damage or did you spawn with it and try to damage another test player?
Could you link me the game and test it on me? I see no reason for it to not work.
One question, is this necessary or what is it for? You say that the Slash animation does not play, but I don’t see where it is.
And you should do this script as one of the server and move the tool to ServerStorage
game.Players.PlayerAdded:Connect(function(player)
local Success, Has = pcall(function()
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19237750)
end)
if Success and Has then
local frozenStick = game:GetService("ServerStorage"):WaitForChild("FrozenStick"):Clone()
frozenStick.Parent = player.Backpack
end
end)
Since the tool isn’t doing the animation, the tool doesn’t do a damage too.
When I played the game with my friends, the tool didn’t do any damage to other players.
if you put the script like this, does it print something?
local tool = script.Parent
local canDamage = false
print("im here")
local function onTouch(otherPart)
print(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then return end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(25)
end
canDamage = false
end
local function slash()
local stringValue = Instance.new("StringValue")
stringValue.Name = "toolanim"
stringValue.Value = "Slash"
stringValue.Parent = tool
canDamage = true
end
print("Connect")
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
Is the following code a LocalScript or a Script? And where is this script located?
local player = game.Players.LocalPlayer
local playerOwnsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19237750)
if playerOwnsGamepass then
local frozenStick = game:GetService("ReplicatedStorage"):WaitForChild("FrozenStick"):Clone()
frozenStick.Parent = player.Backpack
end