Tool's Tween playing on Server on equip, not on Client

I’ve been having an issue with one of the scripts I have in my tool, its suppose to play a Tween whenever I press a GUI to summon the Tool. It works before with 1 player only, but it broke whenever I go test it in-game with somebody.

The Tool Tween is playing on 1 person, but everyone’s equipping it, and it will start to glitch. Can anyone help me?

Normal Script inside the Tool

Phone_Holder:WaitForChild("EquipUnequipEvent").OnServerEvent:Connect(function(Player)
	if equippedStatus[Player] == nil or not equippedStatus[Player] then
		
		
		tool:Clone().Parent = Player.Character
		task.wait()
		onEquip() -- Tween in
		equippedStatus[Player] = true
	else
		onUnequip() -- Tween out
		task.wait(1)
		Player.Character:WaitForChild("Hologram"):Destroy()
		equippedStatus[Player] = false
	end
end)
6 Likes

bump!

can anyone help me with this one? :pensive: been looking through out dev forum and none of the posts are related to mines…

I have disabled the backpack and I force players to equip tool by pressing a gui from a local script, then it fires to the normal script.

3 Likes

The issue its because that script exist inside every tool in game, meaning there are multiple listeners. Player A can call the Server when firing the remote from client, and the server script in the tool that Player B has will listen that call too, populating your table equippedStatus[Player] on both scripts without synchrony.

You gotta make sure that you have only one master script inside ServerScriptService to handle all the functions of the tools, or, if you want to have different server scripts into the tools, make sure you only listen one player owner

4 Likes

What’s the script in onEquip() function? I’m thinking it might be because you are only assigning 1 single tween to handle all of the players’ tween of this tool

3 Likes

@Dev_Peashie ohhh, though, I only want it to play and equip on one player per tool per pressing a GUI on their PlayerGUI.

@hiaihai1 also, the onEquip() is the tween only and they are parented to the tool’s contents

kinda like this:

local tool = -- Tool Itself
local Part1 = tool:WaitForChild("Part1")

-- and inside the OnEquip()
local function OnEquip()
TweenService:Create(Part1, TweenInfo, TweenGoal):Play()
end

Its literally just a tween.


Also my Explorer we’re like this: (Pardon me, I’m not in studio rn)

  1. I have 2 Tools, 1 on ServerStorage and 1 on StarterPack

  2. I have a Button in PlayerGui that Fires a Remote Event
    – The Remote event Fires the Player’s Name that triggered the Button

  3. I have a ServerScript inside a Tool that listens to the Remote Event from the Button
    – It equips the Tool forcefully without using the Backpack
    – It plays the tween (OnEquip) whenever that person Presses the Button

2 Likes

If the tween in the script references only the tool itself that holds that script, then I hardly think the issue could be the what hiaihai1 said.

But I still think that is what I said. You have multiple scripts that can listen to any client. Player B will listen what Player A did from their GUI when firing the remote. So PlayerB’s tool-script will be fired when PlayerA activates their GUI cause its not ignoring all other players incoming remotes calls

3 Likes

The Tool gets cloned per click on the Button to instantly get the player to hold the Item. And the Tool have the ServerScript inside, so maybe that’s the issue?

2 Likes

this is my script on the function inside the tool itself on a serverscript:

local s_f1 = script.Parent:WaitForChild("Border")
local s_f2 = script.Parent:WaitForChild("Border1")

local function onEquip()
	Tween:Create(s_f1, TINFO, {Transparency = 0.2}):Play()
	Tween:Create(s_f2, TINFO, {Transparency = 0.2}):Play()
	Tween:Create(s_f1, TINFO, {Size = Vector3.new(1.7, 0.237, 0.152)}):Play()
	Tween:Create(s_f2, TINFO, {Size = Vector3.new(1.7, 0.237, 0.152)}):Play()

	task.wait(1)
	Tween:Create(Part, TINFO, {Transparency = 0.8}):Play()
	Tween:Create(Part, TINFO, {Size = Vector3.new(2.15, 2.56, 0.102)}):Play()
end

local function  onUnequip()
	Tween:Create(Part, TINFO, {Transparency = 1}):Play()
	Tween:Create(Part, TINFO, {Size = Vector3.new(2.15, 0.01, 0.102)}):Play()

	task.wait(1)
	Tween:Create(s_f1, TINFO, {Transparency = 1}):Play()
	Tween:Create(s_f2, TINFO, {Transparency = 1}):Play()
	Tween:Create(s_f1, TINFO, {Size = Vector3.new(0.05, 0.237, 0.152)}):Play()
	Tween:Create(s_f2, TINFO, {Size = Vector3.new(0.05, 0.237, 0.152)}):Play()
end

image
NOTE: The Local Script here was a Server Script before I posted this, and I have been making tweaks.(the contents inside is still the same as what is in this post)

1 Like

I’m not sure what you mean. But I will insist on what I think the problem is, cause I faced this before.

If you want that a tool has its own ServerScript, and that script is listening Client signals by remotes, the ServerScript on each tool should know what player belongs, in order to ignore what other players does and only perform actions when its owner does the remotes fires.

So a very simple fix is letting know the script who is its owner.
For example, when the Tool is cloned and given to the owner, that script will start to run, (preferably keep it disabled until its given) so when the script starts to run, go to its .Parent owner and keep a variable of who its the owner of that ServerScript, its player instance. So, when a remote event is fired and your ServerScript heard that call you compare with your stored variable Owner, if its the owner perform the task, if its a different player do nothing.

A different workaround could be, having personal remotes per tool, so the ServerScripts are only listening a specific remote which is inside the tool, so each player has its own remotes and those wont interfere with different players.
Or you could handle all actions of all tools with only one single script in SSS, depends on you and what fits you, each approach has pros and cons

2 Likes

I tried some workarounds, and the tool gets equipped on GUI Press, now the tween’s not playing.

What I did is have a Local Script that plays the tween.

I’ll have the ServerScript inside the Tool fire an Client Event to the Tween with the Player’s name only.

I’ll try and see if I can do the own remote per tool

2 Likes

@Dev_Peashie it works, but the tween is not playing. I have a Tween Remote Event inside the tool as well to listen to the Tool inside to play the Tween.

Impossible for me to know why if I dont see the exact structure, scripts and stuff of what you did.
You are using prints() to verify all signals are being listened?

Hold on, let me send the whole structure here:

this is my Tool’s Explorer View:
image

this is where the Events are being fired: (The CorePhoneHandler LocalScript)
image

I have here the ServerScript (which filters the Message that is being sent back to the LocalScript)
image

Basically, the only thing here is the Tool in StarterPack and the LocalScript in StarterGui


Edit:

If you want to see what the Script does, here’s the snippet on the Tool Activation:
CorePhoneHandler:

local BackPack 	= PLAYER_SERVICE.LocalPlayer.Backpack
local Tool 		= BackPack:WaitForChild("Hologram")

EMOTE_BUTTON.MouseButton1Click:Connect(function()
	if BUTTON_BOOL == true then
		TWEEN_SERVICE:Create(PHONE_GUI, TWEEN[3], {Position = UDim2.fromScale(0.113, 0.499)}):Play()
		BUTTON_BOOL = false
		
		Tool:WaitForChild("EquipUnequipEvent"):FireServer(true)
	elseif BUTTON_BOOL == false then
		TWEEN_SERVICE:Create(PHONE_GUI, TWEEN[3], {Position = UDim2.fromScale(-0.5, 0.499)}):Play()
		BUTTON_BOOL = true
		
		Tool:WaitForChild("EquipUnequipEvent"):FireServer(false)
	end
end)

Equip Script inside the Tool:

repeat wait() until script.Parent.Parent:IsA("Backpack")

local replicatedServ = game:GetService("ReplicatedStorage")
local Phone_Holder = replicatedServ:WaitForChild("PhoneHolderFolder")
local plr = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
local equippedStatus = {}

script.Parent:WaitForChild("EquipUnequipEvent").OnServerEvent:Connect(function(Player, state)
	local tool = script.Parent.Parent:WaitForChild("Hologram")
	
	if equippedStatus[Player] == nil or not equippedStatus[Player] then

		tool.Parent = Player.Character
		task.wait()
		equippedStatus[Player] = true
		script.Parent:WaitForChild("TweenEvent"):FireClient(Player, state)
	else
		script.Parent:WaitForChild("TweenEvent"):FireClient(Player, state)
		task.wait(1)
		tool.Parent = Player.Backpack
		equippedStatus[Player] = false
	end
end)

and here’s the TweenAnim LocalScript:

local Tween = game:GetService("TweenService")
local tool = script.Parent.Parent:WaitForChild("Hologram")
local TINFO = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
local Part = script.Parent:WaitForChild("MainScreen")
local equippedStatus = {}

-- supporting frames
local s_f1 = script.Parent:WaitForChild("Border")
local s_f2 = script.Parent:WaitForChild("Border1")

local function onEquip()
	Tween:Create(s_f1, TINFO, {Transparency = 0.2}):Play()
	Tween:Create(s_f2, TINFO, {Transparency = 0.2}):Play()
	Tween:Create(s_f1, TINFO, {Size = Vector3.new(1.7, 0.237, 0.152)}):Play()
	Tween:Create(s_f2, TINFO, {Size = Vector3.new(1.7, 0.237, 0.152)}):Play()

	task.wait(1)
	Tween:Create(Part, TINFO, {Transparency = 0.8}):Play()
	Tween:Create(Part, TINFO, {Size = Vector3.new(2.15, 2.56, 0.102)}):Play()
end

local function  onUnequip()
	Tween:Create(Part, TINFO, {Transparency = 1}):Play()
	Tween:Create(Part, TINFO, {Size = Vector3.new(2.15, 0.01, 0.102)}):Play()

	task.wait(1)
	Tween:Create(s_f1, TINFO, {Transparency = 1}):Play()
	Tween:Create(s_f2, TINFO, {Transparency = 1}):Play()
	Tween:Create(s_f1, TINFO, {Size = Vector3.new(0.05, 0.237, 0.152)}):Play()
	Tween:Create(s_f2, TINFO, {Size = Vector3.new(0.05, 0.237, 0.152)}):Play()
end

script.Parent:WaitForChild("TweenEvent").OnClientEvent:Connect(function(Player, state)
	if state == true then
		onEquip()
	elseif state == false then
		onUnequip()
	end
end)

I never have anticipated how complicated this will become until now :sob:

bump! (character limit)

still need help </3

bump! hoping that I’d get the help I needed :sob: :pray: