为啥这个 Int Value 在设置后会不断返回? [罗布洛克斯工作室]
Posted
技术标签:
【中文标题】为啥这个 Int Value 在设置后会不断返回? [罗布洛克斯工作室]【英文标题】:Why does this Int Value keep coming back after it is set? [Roblox Studio]为什么这个 Int Value 在设置后会不断返回? [罗布洛克斯工作室] 【发布时间】:2022-01-05 22:20:27 【问题描述】:如果这是一个非常简单或容易的问题,我很抱歉,但我正在尝试将玩家 leaderstat "Money" 设置为 0,但它一直作为旧值返回。我能想到的唯一可能导致此问题的是moneyGain 脚本重复。
这是我的 MoneyGain 脚本:
local playerMoney
while wait(0.24) do
local buttons = script.Parent.Parent.info.savedItems.Value.buttons:GetChildren()
for button = 1, #buttons, 1 do
if buttons[button].Parent.Parent.tycoon.Value ~= nil then
if buttons[button].Parent.Parent.tycoon.Value.info.owner ~= nil then
if buttons[button].jobDone.Value == true then
script.Parent.moneyEnforcer.enforce:Invoke(buttons[button].gainVal.Value)
end
end
end
end
--OWNERDOOR:
if script.Parent.Parent.info.owner.Value ~= nil then
script.Parent.moneyEnforcer.enforce:Invoke(1)
end
end
这是我的 moneyEnforcer 脚本:
local rs = game:GetService("ReplicatedStorage")
local dictionary = require(rs.dictionary)
local vipPlayers = dictionary.vipPlayers
script.enforce.OnInvoke = function(amount)
print(amount)
if script.Parent.Parent.info.player.Value ~= nil then
if game:GetService("GamePassService"):PlayerHasPass(script.Parent.Parent.info.player.Value, 25494219) then
amount = amount * 2
else
for i = 1, #vipPlayers, 1 do
if script.Parent.Parent.info.player.Value.Name == vipPlayers[i] then
amount = amount * 2
end
end
end
local playerMoney = script.Parent.Parent.info.player.Value.leaderstats.Money
script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount
end
end
这里是大亨重置器:
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.Parent.Parent.Visible = false
script.Parent.MouseButton1Click:Connect(function()
player.leaderstats.Money.Value = 0
script.Parent.Parent.Parent.Visible = false
local savedItems = player.claimedTycoon.Value.info.savedItems.Value
local builds = player.claimedTycoon.Value.activeBuilds:GetChildren()
local buttons = player.claimedTycoon.Value.activeButtons:GetChildren()
for i = 1, #builds, 1 do
builds[i].Parent = savedItems.builds
end
for j = 1, #buttons, 1 do
buttons[j].Parent = savedItems.buttons
end
savedItems.builds.dirtStarterBase.Parent = player.claimedTycoon.Value
player.claimedTycoon.Value.info:WaitForChild("activeWave").Value = 1
end)
我尝试将“script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount”放在moneyGain上脚本,但这没什么区别。
如有任何帮助,我们将不胜感激!
【问题讨论】:
【参考方案1】:我相信您的问题是您正在从客户端设置货币值。当您从本地脚本更改值时,它不会在服务器上更新。解决此问题从服务器更新值
在tycoon reseter中,尝试使用RemoteEvent从服务器重置值
【讨论】:
以上是关于为啥这个 Int Value 在设置后会不断返回? [罗布洛克斯工作室]的主要内容,如果未能解决你的问题,请参考以下文章
为啥existingObjectWithID 保存后会返回一个带temporaryID 的managedObject?
Navicat for MySQL 为啥我设置的外键保存后会消失?