Tool doesn't work when it is in Repllicated storage

It still doesn’t work even if I put the tools inside Lighting.

It still doesn’t work… :frowning_face:

How did you test whether or not the tool works?

I tested the tools in Roblox Studio.

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.

1 Like

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)
1 Like

That’s a default Roblox animation I think. Some weird hardcoded stuff.

I think the value of the Slash animation is in the StringValue where is says

stringValue.Value = "Slash"

Tool article provides this insight:

But as requested before please provide me with a game link so you can test the tool on me, I don’t think you tested it correctly.

1 Like

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.

Here is the video:
robloxapp-20210629-1307376.wmv (1.1 MB)

Also, I can test with you right now in a server.
Here is the game link:
https://www.roblox.com/games/6962214049/Penguin-Run

wow, why have I never seen that before?

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
1 Like

That script is in a LocalScript, located inside StarterGui.

Ah!
Change that to a Script inside of ServerScriptService.

And give @SOTR654 the solution as they mentioned this before.

1 Like

Now it doesn’t give the tool when I put a script inside a ServerScriptService.

Use the code @SOTR654 provided, that will fix your issue. It’s a few posts up.

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)
2 Likes

Solution without intention? :rofl:

1 Like

Can you please explain me what this means? Thank you.

A pcall() is used to check if the given function works, Success will return true or false depending on whether an error does not jump and can return something, if an error occurs, it will say the error, if not it will return true or false if the player has the game pass.

local Success, Number = pcall(function()
    return "number " + 4
end)
print(Success, Number) -- False, attempt to perform arithmetic (add) on string and number

local Success, Number = pcall(function()
    return "number " .. 4
end)
print(Success, Number) -- true, "number 4"
1 Like