I have a tool shop which will showcase the selected item when clicked. However, these animations can be seen by other players not using the tool stand (as seen in the image above). How would I modify the animation to only be seen by the person who clicked on that object?
Convert it to a local script? If it already is a local script then the player probably has Network Ownership over the animated part which causes it to replicate to the server, just set the network owner to nil
.
I converted them to local scripts and they stopped playing the animations. This is the code I am using for one of them:
local ToolStand = workspace.ToolStand
local AxeFolder = ToolStand.Axes
local Axe = script.Parent.Parent.Parent
local Humanoid = Axe.Humanoid
local Lift = Axe.Lift
local Spin = Axe.Spin
local Track1 = Humanoid:LoadAnimation(Lift)
local Track2 = Humanoid:LoadAnimation(Spin)
script.Parent.MouseClick:Connect(function()
ToolStand.NewToolSelected:Fire(Axe)
for i,v in pairs(ToolStand.Spotlights:GetChildren()) do
if not(v.Name == "Right") then
v.SpotLight.Enabled = false
v.ParticleEmitter.Enabled = false
else
v.SpotLight.Enabled = true
v.ParticleEmitter.Enabled = true
end
end
AxeFolder.StoneAxe.HumanoidRootPart.ClickDetector.MaxActivationDistance = 8
AxeFolder.WoodenAxe.HumanoidRootPart.ClickDetector.MaxActivationDistance = 8
------------------------
Track1:Play()
task.wait(Track1.Length)
Track2:Play()
Track2:AdjustSpeed(0.5)
------------------------
script.Parent.MaxActivationDistance = -1
end)
ToolStand.NewToolSelected.Event:Connect(function(ClickedAxe)
if not(ClickedAxe == Axe) then
Track2:Stop()
end
end)
What does the output say? Try following whatever it says to troubleshoot it for yourself.
No errors in the output. The local script isn’t even registering the click
Then you probably aren’t referencing the click detector.
The script is inside the clickdetector. Would that be causing issues?
idea: Could I possibly send a remote event from the axe to a client-side script and then modify properties from there?
What I would recommend doing is having the server process when the detector is clicked, and then fire a remote to the player to actually create the effect. Theoretically the code you posted earlier should have worked, so if it didn’t, I’d recommend looking over your code for any logical errors.
I think the reason why the local script didn’t do anything is because of where it’s stored. Would it be better to put it somewhere like StarterPlayerScripts?
That is correct. You’ll need to move it to somewhere like StarterPlayerScripts or any client-sided service.
I moved it to StarterPlayerScripts and now things are running. I also checked to see if other players can see the animation and they cannot. I will post an update in a bit once I have all the scripts correctly adjusted to work how they used to.
Updated scripts:
Serverside for all 3 Clickdetectors:
local ToolStand = workspace.ToolStand
local Axe = script.Parent.Parent.Parent
script.Parent.MouseClick:Connect(function(player)
ToolStand.NewToolSelected:FireClient(player,Axe)
script.Parent.AxeAnimation:FireClient(player,Axe)
end)
Client-side for animation:
local ToolStand = workspace.ToolStand
local AxeFolder = ToolStand.Axes
local WoodenAxe = ToolStand.Axes.WoodenAxe
local StoneAxe = ToolStand.Axes.StoneAxe
local IronAxe = ToolStand.Axes.IronAxe
local Humanoid = IronAxe.Humanoid
local Lift = IronAxe.Lift
local Spin = IronAxe.Spin
local Track1 = Humanoid:LoadAnimation(Lift)
local Track2 = Humanoid:LoadAnimation(Spin)
local function Animation(Axe)
local Humanoid = Axe.Humanoid
local Lift = Axe.Lift
local Spin = Axe.Spin
local Track1 = Humanoid:LoadAnimation(Lift)
local Track2 = Humanoid:LoadAnimation(Spin)
for i,v in pairs(ToolStand.Axes:GetChildren()) do
if not(v == Axe) then
v.HumanoidRootPart.ClickDetector.MaxActivationDistance = 30
v.Spotlight.SpotLight.Enabled = false
v.Spotlight.ParticleEmitter.Enabled = false
else
v.HumanoidRootPart.ClickDetector.MaxActivationDistance = -1
v.Spotlight.SpotLight.Enabled = true
v.Spotlight.ParticleEmitter.Enabled = true
end
end
Track1:Play()
task.wait(Track1.Length)
Track2:Play()
Track2:AdjustSpeed(0.5)
ToolStand.NewToolSelected.OnClientEvent:Connect(function(ClickedAxe)
if not(ClickedAxe == Axe) then
Track2:Stop()
end
end)
end
WoodenAxe.HumanoidRootPart.ClickDetector.AxeAnimation.OnClientEvent:Connect(function(Axe) Animation(Axe) end)
StoneAxe.HumanoidRootPart.ClickDetector.AxeAnimation.OnClientEvent:Connect(function(Axe) Animation(Axe) end)
IronAxe.HumanoidRootPart.ClickDetector.AxeAnimation.OnClientEvent:Connect(function(Axe) Animation(Axe) end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.