I want to increase the size variables of a tool in a players backpack using a proximity prompt, then use a different proximity prompt which moves the tool into the workspace and decreases the size variables of the tool.
When the tool is transferred to the workspace and I print the value, the value printed is the size that it is set to in the StarterPack rather than printing the value to which it was increased with the earlier proximity prompt.
Console:
Video of error:
I have tried running print statements to display the tool size variables in the local script and in the server script; both being unfruitful. I tried to use a remote event without success.
--Local script
local detector = script.Parent.Detector
local tool = script.Parent
-- detects water droplets falling into bucket and raises water level accordingly
detector.Touched:Connect(function(part)
if part.Name == "Droplet" and part.Parent == game.Workspace and tool.WaterLevel.Size.X < 1.4 then
tool.WaterLevel.Transparency = .5
tool.WaterLevel.Size = tool.WaterLevel.Size + Vector3.new(.05, 0, 0)
tool.WaterLevel.Position = tool.WaterLevel.Position + Vector3.new(0, .05, 0)
print(tool.WaterLevel.Size.X)
-- increase speed at half full
if tool.WaterLevel.Size.X >= 0.725 and tool.WaterLevel.Size.X < 1.1 then
print("increase speed at half full")
script.Parent.Parent.Humanoid.WalkSpeed = 20
end
-- decrease speed at 3/4 full
if tool.WaterLevel.Size.X >= 1.1 and tool.WaterLevel.Size.X < 1.4 then
print("decrease speed at 3/4 full")
script.Parent.Parent.Humanoid.WalkSpeed = 15
end
-- decrease speed severely at 100% full
if tool.WaterLevel.Size.X >= 1.4 then
print("decrease speed severely at 100% full")
script.Parent.Parent.Humanoid.WalkSpeed = 13
end
end
end)
--Serverscript
local toolEquipped = false
local prompt = script.Parent:WaitForChild("ProximityPrompt")
local targetPart = game.Workspace.ProxPromptHolder
local targetPos = targetPart.CFrame.Position
local function onPromptActivated(player)
if not toolEquipped and player.Character and player.Character.Parent then
local tool = player.Character:FindFirstChild("Bucket")
local bottom = tool:FindFirstChild("Handle")
if tool then
print("tool.WaterLevel.Size:", tool.WaterLevel.Size.X)
print("Sucess!")
bottom.Anchored = true
tool.Parent = game.Workspace
tool.PrimaryPart.CFrame = CFrame.new(targetPart.CFrame.Position)
tool.Handle.CanTouch = false
wait(5)
while tool.WaterLevel.Size.X > 0.1 do
tool.WaterLevel.Size = tool.WaterLevel.Size - Vector3.new(0.05, 0, 0)
tool.WaterLevel.Position = tool.WaterLevel.Position - Vector3.new(0, 0.05, 0)
wait(1)
end
end
end
end
prompt.Triggered:Connect(onPromptActivated)
I believe this is because you are setting the size client side and reading it server side. You will need to detect the water dripping on the server or use remote events for the server to update the size and have the same values as the client.
Create a RemoteEvent in ReplicatedStorage. Use the FireServer method on the client when a water drop hits. From the server, use the .OnServerEvent to detect when a client fires it and connect it to a function. From there, grab the tool the player has equipped(:FindFirstChild(“Whatever your tool is called”) on their character) and copy/paste your client code. Another option would be to do all of this server side to increase security and efficiency with a slight decrease in optimization.
Inside of my “Detector.Touched” function. After that I inserted a print statement into my “proximityPrompt.Triggered” which does print a value… but the value is the same thing; 0.1…
If you have any guidence on this type of thing, tell me. I know its a big ask but it is also a big help for me.
I would recommend just transferring 90% of it to be server sided. Do the hit detection on the server as well as update the size. This will eliminate the inconsistencies between the client and server.
in that case you could just create a serverscript at a glance though one of yours was a serverside script
if you work with tools that is a bonus of them being in the character they can hold their own server and local script and use most the functions that a tool has available
Sorry if its taking so long to reply i’ve just been migrating everything over to one script, testing it and there is a 50/50 chance it doesnt work and i have to restart and find the issue.