Hello DevForum!
-
What do you want to achieve?
What I am aiming to achieve is to create a simulator shop where when a player presses a GUI button it gives them a drink and then they can drink from it with the proper animation -
What is the issue? Include screenshots / videos if possible!
The issue at hand is when a player presses the GUI it gives them the tool however the animation for the tool isn’t working. Whenever I put the tool straight into starterpack the animation works however whenever the tool is received through the GUI the tool’s animation no longer works. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
So far I have tried changing the animation scripts. I have tried going through serverStorage instead of ReplicatedStorage however no solutions have worked.
Give tool script (via GUI)
local tool = game.ReplicatedStorage.SparklingWater
local player = game.Players.LocalPlayer
local backpack = game.Players.LocalPlayer.Backpack
script.Parent.MouseButton1Click:Connect(function()
tool:Clone()
tool:Clone().Parent = backpack
end)
Animation script
local Tool = script.Parent;
enabled = true
function onActivated()
if not enabled then
return
end
enabled = false
Tool.GripForward = Vector3.new(0,-.759,-.651)
Tool.GripPos = Vector3.new(1.5,-.5,.3)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,.651,-.759)
Tool.Handle.DrinkSound:Play()
wait(1)
local h = Tool.Parent:FindFirstChild("Humanoid")
if (h ~= nil) then
if (h.MaxHealth > h.Health + 5) then
h.Health = h.Health + 5
else
h.Health = h.MaxHealth
end
end
Tool.GripForward = Vector3.new(-.976,0,-0.217)
Tool.GripPos = Vector3.new(0.03,0,0)
Tool.GripRight = Vector3.new(.217,0,-.976)
Tool.GripUp = Vector3.new(0,1,0)
enabled = true
end
function onEquipped()
Tool.Handle.OpenSound:play()
end
script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)