You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to change textlabel’s text to Tool’s Strenght Value when ToolActivated
- What is the issue? Include screenshots / videos if possible!
I need help with understanding OnClientEvent or OnServerEvent
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- ToolManager- a normal script
local replicatedStorage= game:GetService("ReplicatedStorage")
local ServerStorage= game:GetService("ServerStorage")
local tools = ServerStorage:FindFirstChild("Tools")
local scripts = ServerStorage:FindFirstChild("Script")
local toolConfig = require(replicatedStorage:FindFirstChild("Config"):FindFirstChild("ToolConfig"))
local remotes = replicatedStorage:FindFirstChild("Remotes")
local kelenko = game:WaitForChild("StarterGui"):FindFirstChild("CurrencyGui"):FindFirstChild("kelenko")
remotes.ToolActivated.OnServerEvent:Connect(function(player, Player)
local playerTool = player.Inventory.EquippedTool.Value
for tool, toolTable in pairs(toolConfig) do
if tool == playerTool then
player.leaderstats.Strenght.Value += toolTable.Strenght
remotes.TextChange:FireClient()
end
end
end)
for _,tool in pairs(tools:GetChildren()) do
local script = scripts.ToolActivated:Clone() -- Bunu template al
script.Parent= tool
end
-- localScript Child of Textlabel
local replicatedStorage= game:GetService("ReplicatedStorage")
local remotes = replicatedStorage:FindFirstChild("Remotes")
local kelenko = game:WaitForChild("StarterGui"):FindFirstChild("CurrencyGui"):FindFirstChild("kelenko")
local toolConfig = require(replicatedStorage:FindFirstChild("Config"):FindFirstChild("ToolConfig"))
remotes.TextChange.OnClientEvent:Connect(function(player,Player)
local playerTool = player.Inventory.EquippedTool.Value
for tool, toolTable in pairs(toolConfig) do
if tool == playerTool then
kelenko.Visible = true
kelenko.Text = toolTable.Strenght
end
end
end)
-- LocalScript Child of tools
local replicatedStorage= game:GetService("ReplicatedStorage")
local remotes = replicatedStorage:FindFirstChild("Remotes")
local tool = script.Parent
tool.Activated:Connect(function()
remotes.ToolActivatedRemote:FireServer()
print("text")
end)
it seems like I am doing something wrong with usage of OnClientEvent, OnServerEvent Usage.
please help.
I don’t know if you need them but here is the screenShot of the scripts I mentioned with their locations