Hi, I was wondering if there was a way to change a parts special mesh if they click a button and if they have > 100 coins (Client-Sided)
local WS = game:GetService("Workspace")
local TPS = WS:WaitForChild("TPS"):WaitForChild("Design")
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local stat = plr:WaitForChild("Leaderstatss").Coins.Value
local meshID = 4582910212
local textureID = 4761214875
script.Parent.MouseButton1Click:Connect(function()
if stat == 0 then
stat -= 0
TPS.MeshId = meshID
TPS.TextureId = textureID
warn("Bought")
else
end
end)
You could just store a cloned mesh in ReplicatedStorage but with it’s mesh edited [Only edit mesh Id through properties]
Then If that person clicks on it, you clone the cloned mesh in workspace.
local WS = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ball = WS:WaitForChild("TPS")
local TPS = WS:WaitForChild("TPS"):WaitForChild("Design")
local Mesh = ReplicatedStorage:WaitForChild("Design")
local plr = Players.LocalPlayer
local stat = plr:WaitForChild("Leaderstatss").Coins.Value
local meshID = 4582910212
local textureID = 4761214875
script.Parent.MouseButton1Click:Connect(function()
if stat == 0 then
stat -= 0
TPS:Destroy()
Mesh.MeshId = meshID
Mesh.TextureId = textureID
Mesh:Clone().Parent = ball
warn("Bought")
else
warn("You dont have enough coins!")
end
end)
You can use a RemoteFunction to do a sanity check, because an exploiter can edit Coins’ value on the client and give a false change.
local RS = game:GetService("ReplicatedStorage")
RS.RemoteFunction.OnServerInvoke = function(client)
if client.leaderstats.Coins.Value > 100 then
return true
else
return false
end
end
local RS = game:GetService("ReplicatedStorage")
local Result = RS.RemoteFunction:InvokeServer()
if Result then
-- Change MeshID locally.
end
Like I said, do not edit it through script, Make a MeshPart in studio then set the Mesh Id and Texture Id through properties then place it in ReplicatedStorage.
If the player clicks on it, you clone the mesh part then parent it to workspace.